views:

195

answers:

2

Hi, I have 2 Gridviews which share the same OnSelectedIndexChanged event. How do I get the incoming Gridview the one which fired so that I can pass that GridView to DetailsView. In that DetailsView I need to access the selected Gridview columns.

Thanks In Advance.

+1  A: 

The "sender" parameter of the OnSelectedIndexChanged event should be the GridView that the event came from. You can get at it like this:

public void MyGrid_OnSelectedIndexChanged(object sender, EventArgs e)
{
    GridView grid = sender as GridView;
    if (grid != null)
    {
        // Do something with grid
    }
}
d4nt
+3  A: 

first parameter is "sender" as an object and you can cast it to a gridview object than check its ID.

GridView grd = (GridView) sender;

Cem