Consider a GridView that contains three columns: First Name, Alien Dropdown and Country Dropdown. The Alien Dropdown has two options, Yes and No. Select Yes in the Alien Dropdown. The Country Dropdown is enabled.

Both Dropdowns are defined in a TemplateColumn. For this example, we bind the GridView to a XmlDataSource.

Handle the RowDataBound event of the GridView. In the event handler, we check if Alien Dropdown has a value of Yes. If Yes, we enable the Country Dropdown.

Each item in a XmlDataSource is a XmlDataSourceNodeDescriptor. To get the XmlNode attributes, use the XPathBinder. Finally, we handle the OnSelectedIndexChange event of the Alien Dropdown.

To get the GridViewRow where the Dropdown is present, use NamingContainer property of the control. Use  FindControl method to find the Country Dropdown. Enable or Disable the Country Dropdown based on the value in the Alien Dropdown.

Handling Dropdown event within GridView
Tagged on: