开发者

ASP.NET 2 Gridviews share the same OnSelectedIndexChanged event

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜