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

Releated RadComboBox in RadListView

1 Answer 78 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Rizwan Ansari
Top achievements
Rank 1
Rizwan Ansari asked on 22 Dec 2013, 08:41 AM
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 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Dec 2013, 04:49 AM
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.
Tags
ListView
Asked by
Rizwan Ansari
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or