Get values from ItemTemplate OnClientSelectedIndexChanged

5 posts, 2 answers
  1. KorsG
    KorsG avatar
    8 posts
    Member since:
    Mar 2009

    Posted 26 Apr 2010 Link to this post

    I have a combobox, that when changed, should change the selected value of 2 other comboboxed based on the selection.

    <telerik:RadComboBox ID="RadComboBox1" runat="server"  DataTextField="Name" DataValueField="ActTypeNo"                                              
        OnClientSelectedIndexChanged="OnClientSelectedIndexChanged"  > 
             <td style="width: 200px;"
                     <asp:Label ID="ChaufName" runat="server" EnableViewState="false" Text='<%#DataBinder.Eval(Container.DataItem, "Name")%>'></asp:Label> 
           <td style="display:none;"
               <asp:Label ID="ChaufGr1" runat="server" EnableViewState="false" Text='<%#DataBinder.Eval(Container.DataItem, "Gr1")%>'></asp:Label> 
           <td style="display:none;"
               <asp:Label ID="ChaufGr2" runat="server" EnableViewState="false" Text='<%#DataBinder.Eval(Container.DataItem, "Gr2")%>'></asp:Label> 

    My goal is to get the values of "ChaufGr1" and "ChaufGr2" in a javascript function:
    function OnClientSelectedIndexChanged(sender, args) { 
                    //get values 
                    //set selected value of other combos - i know how to do this 

    I have searched the documentation and forums, but i couldn't find anything exactly like this. 
    Can you point me in the right direction?
  2. Answer
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 26 Apr 2010 Link to this post

    You should them as attributes to the RadComboBoxItem similar to this RadListBox example:

    So you could loop through the RadComboBox.Items collection and add the attributes to each one. Then you can retrieve the values from the attributes collection.

    I hope that helps.
  3. Answer
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Apr 2010 Link to this post


    In fact, Robert said is correct. You can make use of custom attribute in order to get additional values. Here is the example that I tried for similar scenario.


        protected void RadComboBox1_ItemDataBound(object sender, Telerik.Web.UI.RadComboBoxItemEventArgs e)  
            DataRowView dataSourceRow = (DataRowView)e.Item.DataItem;  
            //set custom attributes from the datasource:      
            e.Item.Attributes["Gr1"] = dataSourceRow["Gr1"].ToString();  
            e.Item.Attributes["Gr2"] = dataSourceRow["Gr2"].ToString();    


    <script type="text/javascript">  
        function OnClientSelectedIndexChanged(sender, args) {  
            var item = args.get_item();  
            // Alert the values  


  4. KorsG
    KorsG avatar
    8 posts
    Member since:
    Mar 2009

    Posted 28 Apr 2010 Link to this post

    Thank you both, this helped me solve my problem! :-)

    My final js and code behind ended up like this:
    function OnClientSelectedIndexChanged(sender, args) { 
                    //get values 
                    var item = args.get_item(); 
                    var gr1ID = item.get_attributes().getAttribute("Gr1"); 
                    var gr2ID = item.get_attributes().getAttribute("Gr2"); 
                    //set values 
                    var gr1Combo = $find("<%=Gr1Combo.ClientID%>"); 
                    var gr1Item = gr1Combo.findItemByValue(gr1ID); 
                    if (gr1Item) { 
                    var gr2Combo = $find("<%=Gr2Combo.ClientID%>"); 
                    var gr2Item= gr2Combo.findItemByValue(gr2ID); 
                    if (gr2Item) { 

    As i use a LinqDataSource i had to use the databinder
    Protected Sub Chauffeurs_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemEventArgs) Handles Chauffeurs.ItemDataBound  
            e.Item.Attributes("Gr1") = DataBinder.Eval(e.Item.DataItem, "Gr1")  
            e.Item.Attributes("Gr2") = DataBinder.Eval(e.Item.DataItem, "Gr2")  
        End Sub  

  5. Aruldoss
    Aruldoss avatar
    1 posts
    Member since:
    Aug 2017

    Posted 02 Nov 2017 Link to this post

    how to get ComboBox Value

           List<Student> students=new List<Student>();

               Student student1=new Student();






               Student student2=new Student();


                RadComboBox1.DataSource = students;
                RadComboBox1.DataTextField = "Name";
                RadComboBox1.DataValueField = "Id";

    how to get Student of code from selected combobox value





Back to Top