开发者

How to access elements of a gridview

i have a asp buttonfield in a asp:gridview as follows

<asp:ButtonField ButtonType="Button" CommandName="Select" HeaderText="View" ShowHeader="True" Text="View" />

How do I access this element and give it some functionality(meaning, when i click the button, I want it to 开发者_StackOverflowdo something and not stare at me !)

thanks in advance


The CommandName value allows you to trap the command you wish to execute when the button is clicked. This event is raised by the GridView and can be trapped in the RowCommand event. A small snippet below:

  void MyGridView_RowCommand(Object sender, GridViewCommandEventArgs e )
  {
    if(e.CommandName=="Select")
    {
      DoSomething();
    }
  }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜