How can i get row index of the grid view whose child control is doing post back. I know the way of getting control causing post back and finding its parent container which returns grid view row and then find its index. I want this in a RowDataBound event to check selectedrow index and formatting the same. Is there any other property or settings which directly emits selected index of the grid view on any child control post back
Edit:
For example if there is a dropdownlist in a row and there are certain rows in a gridview. Then i want gridview rowindex where postback happens due to that dropdowlist in the gridview row.
You can get the index of the row in
RowDataBoundvia theRowIndexproperty:You can get the index of any child control in a GridView via
childControl.NamingContainer=>GridViewRow=>RowIndexfor example in a
DropDownList.SelectedIndexChangedevent:Finally: since you’ve mentioned ” to check selectedrow index”, if you’re actually looking for the selected row index of the
GridViewitself, there’s a property just for this:GridView.SelectedIndexProperty