views:

650

answers:

2

I have a Template Column under which I have Placed a Dropdownlist. Now I would Like to get the selectedRow of the datagrid on selectedIndeChanged event of the dropdownlist that's inside the template Column

+1  A: 

You can get the index of the item in the datagrid, by looking at the DataGridItem your dropdownlist is contained within.

Assuming your DropDownList is directly in the TemplateColumn and is not wrapped by other elements, then the following example shows how to do this:

 protected void DropDown_SelectedIndexChanged(object sender, object eventdata)
 {
  int gridRowIndex = ((DataGridItem)((DropDownList)sender).Parent.Parent).ItemIndex;
 }
Tom Jelen
A: 

Does DataGrid1.SelectedIndex help?

DataGrid1 = Name of the variable that is the name of the DataGrid control on the page.

shahkalpesh