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

[Solved] Binding dropdown in grid depending what is selected in another dropdown in the grid

1 Answer 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 04 Mar 2013, 09:28 AM
I need to bind a dropdown list depending on what is selected in another dropdown. I know i need to attach a selectedindexchanged event to the first dropdown but i am unsure on how to reference the second the dropdown to rebind within the selectedindexchanged event. Any help would be greatly appreciated.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Mar 2013, 10:05 AM
Hi,

Try the following code to achieve your scenario.
C#:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
   {
       DropDownList ddl = (DropDownList)sender;
       GridDataItem item = (GridDataItem)ddl.NamingContainer;
       DropDownList ddl1 = (DropDownList)item.FindControl("DropDownList2");
   }

Thanks,
Shinu
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or