Releated RadComboBox in RadListView

2 posts, 0 answers
  1. Rizwan Ansari
    Rizwan Ansari avatar
    26 posts
    Member since:
    Nov 2009

    Posted 22 Dec 2013 Link to this post

    Dear Expert,

    I have a radlistview and on edit mode i have two radcombobox, now i want to fill first radcombox and based on selection another radcombobox should fill, how can i achieve this. please help.

    Thanks 
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 22 Dec 2013 Link to this post

    Hi Rizwan Ansari,

    Please have a look into the following C# code snippet to achieve your scenario.

    C#:
    Telerik.Web.UI.RadComboBox combo1;
    protected void RadListView1_ItemCreated(object sender, RadListViewItemEventArgs e)
    {
        if (e.Item is RadListViewEditableItem && e.Item.IsInEditMode)
        {
            combo1 = e.Item.FindControl("RadComboBox2") as RadComboBox;
        }
    }
    protected void RadComboBox1_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
    {
        Telerik.Web.UI.RadComboBox combo = (Telerik.Web.UI.RadComboBox)sender;
        String connstring = WebConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
        SqlConnection conn = new SqlConnection(connstring);
        SqlDataAdapter adapter = new SqlDataAdapter();
        adapter.SelectCommand = new SqlCommand("SELECT Cityname from City WHERE Countryname LIKE '" + e.Text + "%'", conn);
        DataTable data = new DataTable();
        conn.Open();
        try
        {
            adapter.Fill(data);
            combo1.DataSource = data;
            combo1.DataTextField = "Cityname";
            combo1.DataBind();
        }
        finally
        {
            conn.Close();
        }
    }

    Hope this will helps you.
    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top