开发者

how to get row index on btn click which is out side of the grid

I have a button 开发者_开发百科out of GridView. I want to get the row index on that button click. How to get it?

I used

GridViewRow row = ((Button)sender).Parent.Parent as GridViewRow;

but it's not working.


If the Button out of the GridView the Button parent is an other container (maybe a Form or a Panel) not the GridView.

  • First of all you need a reference to the GridView. If you have a variable what contains this reference you should use that. If you haven't variable, you should search the GridView:

    GridView grd = this.FindControl("GridViewName");
    
  • After that you can get the GridViewRow:

    GridViewRow row = grd.SelectedRow;
    
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜