This is a migrated thread and some comments may be shown as answers.

Combo box combine text from multiple fields

1 Answer 538 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Farhan
Top achievements
Rank 1
Farhan asked on 06 Sep 2011, 06:55 PM
Hi,

   I have a combo box in the edit Form in a radgrid. Im using Entity Framework and a business layer class to return an IEnumerable List
<Employees> to bind to the grid. When the edit form comes up I want the titles and names of the employees to be shown in the combo box. like as the  DataTextField like :

"{Title}:" + {FirstName}  + " " + {LastName}

and I want to bind another property in the Employee class employee_Id as the DataValueField.

Can someone show me how to do this, I am doing something similar in a GridCalculatedColumn where I am able to combine these multiple fields and show them in an expression like shown above. Please see Grid calculated column below. How can I bind the combo box like this so i can see the title: FirstName  Lastname  in the text field. Please note that I dont want a multi column grid as shown in this example here
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multicolumncombo/defaultcs.aspx  

I want to show them all together. and be able to bind the employee_id property as the DataValueField so when i submit the form I can read that, can someone please show me how to do this in code, thanks.   Please see below for the CalculatedGridColumn where i am showing same information.

<telerik:GridCalculatedColumn SortExpression="Employee.FirstName" HeaderText="Employees" AutoPostBackOnFilter="true"
 DataFields="Employee.Title,Employee.FirstName, Employee.LastName" Expression='{0}  + ":" + {1} + " " + {2}' >                        
 <HeaderStyle HorizontalAlign="Left" Width="30%" />
                         <ItemStyle HorizontalAlign="Left" />
                    </telerik:GridCalculatedColumn>

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Sep 2011, 04:31 AM
Hello Farhan,

You could use the custom attributes to achieve your functionality. You can fine the more information from here.

Custom Attributes.
ComboBox / Custom Attributes .

Thanks,
Shinu.
Tags
ComboBox
Asked by
Farhan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or