开发者

How to access elements of a gridview

开发者 https://www.devze.com 2023-02-11 23:27 出处:网络
i have a asp buttonfield in a asp:gridview as follows <asp:ButtonField ButtonType=\"Button\" CommandName=\"Select\" HeaderText=\"View\" ShowHeader=\"True\" Text=\"View\" />

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

精彩评论

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