Get SelectedRow from DataGrid in dropdown_SelectedIndexChanged event ASP.Net, C #

I have a templates column that I have placed a Dropdownlist in. Now I would like to get the selected Row value for the datagrid in the selectedIndeChanged event from the dropdown that is inside the Column template

0


source to share


2 answers


You can get the index of an item in the datagrid by looking at the DataGridItem the dropdown is in.

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



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

      

+1


source


Does DataGrid1.SelectedIndex help?



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

0


source







All Articles