我在gridview中放了一个ButtonField按钮
  怎样通过点击获取到它text属性中值

解决方案 »

  1.   

    在页面上右键查看源码,找出ID规律,然后用JS取
      

  2.   

    把ButtonField转换成TemplateField.
    <asp:TemplateField HeaderText="测试">
                        <ItemTemplate>
                            <asp:Button ID="Button1" runat="server" CausesValidation="false" OnClientClick="alert(this.value); return false;"
                                CommandName="Cancel" Text="按钮" />
                        </ItemTemplate>
    </asp:TemplateField>
      

  3.   

    <asp:ButtonField Text="buttonfield"  CommandName="link"/>
      protected void gridview_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "link")
            {
                int intRow = int.Parse(e.CommandArgument.ToString()); //获取当前所在行
                  
            }
        }