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

Using multiple columns for DataTextField

3 Answers 908 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
bill
Top achievements
Rank 1
bill asked on 30 Aug 2010, 06:05 PM
Is there a way to specify multiple data text field columns?  It would also be nice to beable to use the format string.  Some thing like this:

DataTextField

 

="ratecode;description" DataTextFormatString="{0} - {1}" DataValueField="rateid"

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 31 Aug 2010, 07:10 AM
Hello,


You can easily achieve this by using following code in ItemDataBound event.

C#:
protected void RadComboBox1_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
{
    DataRowView dataSourceRow = (DataRowView)e.Item.DataItem;
    e.Item.Text = e.Item.Text + " - " + dataSourceRow["description"].ToString();
}


-Shinu.
0
Patrice Boissonneault
Top achievements
Rank 1
answered on 21 Feb 2012, 09:03 PM
This does not work with client-binding though.  Is this going to be supported in the future?
0
Ivana
Telerik team
answered on 24 Feb 2012, 01:09 PM
Hello Patrice,

You can use attributes to achieve this functionality when RadComboBox is bound to a Web service.
In the .cs file where the items are loaded, you can add attributes to the RadComboBoxItemData object and in the client SelectedIndexChanged event do the following to set text in the input area:
function OnClientSelectedIndexChanged(sender, args) {
    var item = args.get_item();
    if (item != null) {
        sender.set_text(item.get_text() + " + " +
        item.get_attributes().getAttribute("test"));
    }
}
(See attached files.)

I hope this helps.

All the best,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ComboBox
Asked by
bill
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Patrice Boissonneault
Top achievements
Rank 1
Ivana
Telerik team
Share this question
or