Multi Column Rad Combo

2 posts, 0 answers
  1. Rahul
    Rahul avatar
    14 posts
    Member since:
    Feb 2013

    Posted 11 Jun 2013 Link to this post


    As per the client requirement i will be having 2 combo box on my screen 1 combobox will be single column and other will be multicolumn. first Combo box will get populated on page load and second will get populated as per the value selected in First combo box. please let me know how can i do this, i want to populate both the combobox on server side.

    i have done one example but when i am trying to get the selected value from first combo i am getting blank values. please let me know that how can i get the selected value of single column rad combo and multicolumn rad combo.

    bellow  is my code.
    ASPX page
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <head runat="server">
        <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                <%--Needed for JavaScript IntelliSense in VS2010--%>
                <%--For VS2008 replace RadScriptManager with ScriptManager--%>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        <script type="text/javascript">
            //Put your JavaScript code here.
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <telerik:RadComboBox ID="RADClasification"  EnableLoadOnDemand="True" 
                Runat="server" onitemsrequested="RADClasification_ItemsRequested" 
             <telerik:RadComboBox ID="RadTemplateGroup" Runat="server"  
                    EnableLoadOnDemand="True" onitemsrequested="RadTemplateGroup_ItemsRequested">
                             <li>Template Group name</li
                             <li>Effective Date</li>
                                  <%# DataBinder.Eval(Container.DataItem, "Template_GroupName")%></li
                                  <%# DataBinder.Eval(Container.DataItem, "EffectiveDate")%></li
                        A total of 
                        <asp:literal runat="server" id="RadComboItemsCount" /> 
    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using System.Configuration;
    using System.Web.Security;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using Telerik.Web.UI;
    public partial class Default : System.Web.UI.Page 
        protected void Page_Load(object sender, EventArgs e)
        protected void RADClasification_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
            RADClasification.DataSource = CreateDatatable();
            RADClasification.DataValueField = "Cat_ID";
            RADClasification.DataTextField = "Description";
        private DataTable CreateDatatable()
            DataTable dt = new DataTable();
            dt.Columns.Add("Cat_ID", typeof(int));
            dt.Columns.Add("Description", typeof(string));
            for (int i = 1; i <= 10; i++)
                dt.Rows.Add(i, "Catagory" + i.ToString());
            return dt;
        private DataTable PopulateTemplateGroup()
            DataTable Dt = new DataTable();
            if (Convert.ToInt32(RADClasification.SelectedValue) > 4)
                Dt.Rows.Add(1, "TG1", "10-May-2013");
                Dt.Rows.Add(2, "TG2", "10-May-2013");
                Dt.Rows.Add(3, "TG3", "10-May-2013");
                Dt.Rows.Add(4, "TG4", "20-May-2013");
                Dt.Rows.Add(5, "TG5", "20-May-2013");
                Dt.Rows.Add(6, "TG6", "20-May-2013");
            return Dt;
        protected void RADClasification_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        protected void RadTemplateGroup_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
            RadTemplateGroup.DataSource = PopulateTemplateGroup();
        protected void RADClasification_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
            e.Item.Text = ((DataRowView)e.Item.DataItem)["Description"].ToString();
            e.Item.Value = ((DataRowView)e.Item.DataItem)["Cat_ID"].ToString();   

  2. Plamen
    Plamen avatar
    3057 posts

    Posted 14 Jun 2013 Link to this post

    Hi Rahul,

    This is an expected behavior because  onitemsrequested event is making a callback and you can not get the state of the other controls in from it.

    One possible workaround it so set AutoPostBack="true" to the first RadComboBox that will let you get the selected value.

    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 the blog feed now.
Back to Top