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

How to show Value which one not containing in Combo box but brought in data source. - URGENT PLEASE

1 Answer 25 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Manish
Top achievements
Rank 2
Manish asked on 16 Dec 2016, 11:39 AM

For Better understaning my problem go through the Image I have attached.

scenario is that I have two values in rad combo box 1 setting in Value field and 1 in Test Field and the 3rd one I have show in another label depending on selected value. 

Means if I have 3 users and total marks 

StudendId - Name - Total Marks

     1          -   Studend1 - 50

     2          -   Studend2 - 60

     3          -   Studend3 - 70

Now I have show 70 in a separate label if I select Student3 to do this as it is only single value I don't want to make any round trip to server. Please help.

 

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 20 Dec 2016, 02:22 PM
Hello Manish,

If you want to use a third field from the datatable (CellActiveArea) you can do so by setting it as a custom attribute to the ComboBox items. The following section of the documentation shows how this can be achieved. You need to subscribe to the ItemDataBound event and in its handler set the custom attribute:
protected void RadComboBox1_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
{
    DataRowView dataItem = (DataRowView)e.Item.DataItem;
    e.Item.Attributes["CellActiveArea"] = dataItem["CellActiveArea"].ToString();
}

Then on the client you can use the item's client-side API to get the value from the item's custom attribute. Here's an example how this can be done in the ComboBox OnCLientSelectedIndexChanged event handler:
function OnClientSelectedIndexChanged(sender, args) {
    var item = args.get_item();
    alert(item.get_attributes().getAttribute("CellActiveArea"));
}



Regards,
Ivan Danchev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
ComboBox
Asked by
Manish
Top achievements
Rank 2
Answers by
Ivan Danchev
Telerik team
Share this question
or