I have a RadComboBox that shows two columns in the drop down, I have a header for them as well. I want the 2 columns to show once the item is selected. I'm new to Telerik, so I'm not sure if I'm saying this correctly, but I essentially would like a DataTextField ='ID + Name".
Is there a way to make 2 datatextfields show up in the selected value of a RadComboBox, either in ASP.Net, or VB/C#?
Thank you,
J
6 Answers, 1 is accepted

Let met restate what I think you are basically asking. You wish to, using databinding, have the items displayed in a combobox have two data points which are uniquely databound.
Have you looked at item templates? I would seem that they are custom made for what you are asking.

Thanks for your reply. I will try to graphically show what's going on as I don't think I'm describing it well.

The 6-49-28 photo shows what happens after you click something in the drop down.
6-50-05 shows what the drop down looks like, it has two columns worth of data in the drop down. I would like both columns to show in the drop down once it's selected, instead of just one column. Is that possible? If so, what should I learn more about please? Any links to documentation would be helpful as I'm not sure how to verbalize what I'm looking to do.

Ok, I think you are trying to say that you wish the final selected items value to display whatever you selected in the displayed drop down list of items.
That is to say if your drop down list displays in pretty formatted layout, with whatever the content you choose, you want the final selected item displayed to be that same formatted layout and not the "DataTextField" or "DataValueField" properties.
TO be honest, I cannot find a way to do it. Effectively it would have to be done client side as the selected item could change without a round trip to the server. A way to cheat this would be to have a third property that contains both fields formatted into a single text field. You would then display this field rather than the actual single field you currently display. The drop down display will still render correctly then the selected value would be this third property.
Telerik would have to provide us with a template for the "selectedItem". WPF seems to have been started along that path.


Well, after declaring defeat, I found a solution. Here is a snippet of a combobox control which uses an object datasource to bind to your data. One trick I used. I provided an overload of the ToString method on the object I am binding to. By doing this, the default behavior of the combobox uses this overload to display the selected value. This allows you to design both the drop down layout (by how you layout the item template) and to also layout the selected value by altering the ToString overload.
Here is also my implementation of the AppData object. You obviously will want to do something different but it should give you some ideas:
using
System.Collections.Generic;
namespace
ASpace
{
public
class
AppData
{
public
int
AppId {
get
;
set
; }
public
string
AppName {
get
;
set
; }
public
AppData(
int
appId,
string
appName
)
{
this
.AppId = appId;
this
.AppName = appName;
}
public
AppData() :
this
(0,
string
.Empty) { }
public
static
List<AppData> ReadDb()
{
return
new
List<AppData>() {
new
AppData(214,
"Customer Care"
),
new
AppData(215,
"Driver Services"
),
new
AppData(216,
"Project Management"
)
};
}
public
override
string
ToString()
{
return
string
.Format(
"{0} - {1}"
,
this
.AppId.ToString().PadRight(5,
' '
),
this
.AppName);
}
}
}
<telerik:RadComboBox ID=
"RadComboBox1"
runat=
"server"
DataSourceID=
"ObjectDataSource1"
DataValueField=
"AppId"
>
<ItemTemplate>
<table>
<tr>
<td>
<%# DataBinder.Eval(Container.DataItem,
"AppId"
) %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem,
"AppName"
) %>
</td>
</tr>
</table>
</ItemTemplate>
</telerik:RadComboBox>
<asp:ObjectDataSource ID=
"ObjectDataSource1"
runat=
"server"
SelectMethod=
"ReadDb"
TypeName=
"ASpace.AppData"
></asp:ObjectDataSource>