Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1230
Display TextField with many values
posted

I have a WebDataGrid which is bound to database table.

In this table, one of the field displayed is the ID of a person.

Of course, What I would like to do is:

  • Have the field in read only
  • Display the Name and Surname of the user instead of his ID

What is the best choice to achieve so ? 

At this time, I'm using a DropDownProvider to get the result but I'm stuck because I am only able to show the Name or the surname but not both.

My dropDownProvider is linked to a SqlDatasource getting the ID, Name and Surname form my Contact table. 

The ValueField used is ID (of course to get the equivalent with the grid column containing the contact ID)

and the TextField is "Name" or "Surname"...

What I would like to do is someting like : Textfield = Name + Surname

How to achieve this ? 

Thanks

Parents
  • 49378
    posted

    Hello Nicolas,

    As the most straightforward approach in this scenario I would suggest adding another column to the source DataTable, whose values would be based on the desired First name and Surname columns.

    An alternative approach would be to use ItemTemplating and the DataBinder:

       <ig:WebDropDown ID="WebDropDown1" runat="server" Width="200px">
                <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem,"Name"%>   <%# DataBinder.Eval(Container.DataItem,"Name2"%>
                </ItemTemplate>
            </ig:WebDropDown>
     
    This approach however would require also handling the clientside value and selection changing events in order to control the value displayed in the input field (as the selected
    value would in this case show as only the value of one of the data source fields.
    Hope this helps. Please do not hesitate to contact me if you have any questions.

Reply Children
No Data