开发者

ASP.NET 2 Gridviews share the same OnSelectedIndexChanged event

开发者 https://www.devze.com 2022-12-09 00:56 出处:网络
I have 2 Gridviews which share the same OnSelect开发者_JAVA技巧edIndexChanged event. How do I get the incoming Gridview the one which fired so that I can pass that GridView to DetailsView. In that Det

I have 2 Gridviews which share the same OnSelect开发者_JAVA技巧edIndexChanged 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.


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

GridView grd = (GridView) sender;


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
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消