views:

463

answers:

1

hello, I need to aske I have gridview with combobox template column and its fill with items . when select index changed i need to set description value in onther cell but I couldn't get the index of the gridview row? any help

A: 

It's a little unclear which SelectedIndexChanges you are talking about, but I assume you think about the combobox SelectedIndexChanged.

Assuming you have hooked up the eventhandler on the combobox, you can use the following code to get the RowIndex inside the handler

protected void cmb_SelectedIndexChanged(object sender, EventArgs e)
{
   int idx = (((sender as System.Web.UI.WebControls.DropDownList).Parent.Parent as GridViewRow)).RowIndex;
}

Parent of the dropdownlist will be a DataControlField and the parent if it will be the GridRow.

This also assumes you have no other container controls inside your templatefield, as the parent.parent structure then could be different.

Bjorn Isaksen