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

Load on demand with two comboboxes in grid

3 Answers 134 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Silvio Silva Junior
Top achievements
Rank 2
Silvio Silva Junior asked on 15 Apr 2010, 03:40 PM
Hello guys.

I have a doubt about combobox in radgrid.

My grid have two comboboxes (in two GridTemplateColumns) when in editmode: one for State and other for city. In the State combobox SelectedIndexChanged event, I want to populate my City combobox, but I don't know how to get the city combobox in the SelectedIndexChanged event of State combobox. I have tryed some like this:

RadComboBox ddlCity = (RadComboBox)RadGrid1.FindControl("ddlCity "); but it doesn't work.

How can I do?

Thanks in advance.

Regards.

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 16 Apr 2010, 12:24 PM
Hello Silvio,

You could hook OnSelectedIndexChanged event to the RadComboBox and get reference to the second combobox (by accessing the container and then FindControl) and populate the combo in that event. Check out the following code:

C#:
 
protected void RadComboBox1_OnSelectedIndexChanged(object sender, EventArgs e)   
    RadComboBox radCombo1 = (RadComboBox)sender;   
    GridEditFormItem editItem = (GridEditFormItem) radCombo1.NamingContainer;   
    RadComboBox radCombo2 = (RadComboBox)editItem.FindControl("radCombo2");   
    radCombo2.ClearSelection(); 
    radCombo2.DataSource = BindSecondCombo(radCombo1.SelectedValue); // Retrieve the items corresponding to selectedvalue of first combo (State) 
    radCombo2.DataTextField = "City";   
    radCombo2.DataValueField = "Id";   
    radCombo2.Items.Insert(0, new RadComboBoxItem("Select City...""0"));   


Thanks,
Princy.
0
Silvio Silva Junior
Top achievements
Rank 2
answered on 19 Apr 2010, 03:05 PM
Very thanks Princy.

It work's fine!!!

Thank you bro.


0
Rick
Top achievements
Rank 1
answered on 23 Dec 2010, 02:17 PM
Thanks for the fast reply. That looks like it will work.

Thanks Princy.
Tags
Grid
Asked by
Silvio Silva Junior
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Silvio Silva Junior
Top achievements
Rank 2
Rick
Top achievements
Rank 1
Share this question
or