Cascading DropDownList in a GridView
I'm trying to put a series of three cascading dropdownlist controls in the EditItemTemplates of a GridView.
This is for a small college's online registration system, and the dropdowns correspond to Departments (e.g. Math, English, Science etc.) , Courses (e.g. Calculus, Trig, Algebra etc.) and Sections (e.g. three sections of Calc I on different days and times, and different locations).
I've managed to get the sucker working outside of a GridView, by:
1) declaratively setting the datasource to a method that returns a dataView, e.g. DataSource = "<%# PopulateCourseDropDown(1) %>" where the 1 corresponds to the first Department in the parent dropdown, and
2) writing a SelectedIndexChanged event handler for each parent dropdown which calls the same method for its child, passing instead of a 1 the selectedValue from the parent, then re-binding.
This all works great, although I do wish they let you declaratively set the selectedValue property instead of forcing you to do it in code (minor nuisance).
Trouble is, when I put the whole thing in a GridView's EditItemTemplate, it stops working. The SelectedIndexChanged event still fires, and I can get into the handler method, I just can't seem to get a reference to the other dropdowns in the row, so I can't reset their datasources or re-bind them.
Do I need to bubble up the SelectedIndexChanged event into the GridViewRow, and handle it in a GridViewRow_Command event handler? Is that even possible? How would I differentiate between events coming from the various dropdowns?
Thanking you all for your input in advance!