被常常问到的一个经典问题了,答案放到网上来。

步骤
1 ASP.NET的这个地方这样设置。GridView加入 OnRowCommand 事件,模版列的按钮设置CommandArgument、CommandName
获取模版列中按钮事件所在行的关键字        <asp:GridView ID="GridView1" runat="server" CellPadding="4" AutoGenerateColumns="False" OnRowCommand="GridView1_RowCommand">
获取模版列中按钮事件所在行的关键字            
<Columns>
获取模版列中按钮事件所在行的关键字                
<asp:BoundField DataField="id" HeaderText="编号" />
获取模版列中按钮事件所在行的关键字                
<asp:BoundField DataField="loginID" HeaderText="登陆名" />
获取模版列中按钮事件所在行的关键字                
<asp:TemplateField HeaderText="工具栏权限管理">
获取模版列中按钮事件所在行的关键字                    
<ItemTemplate>
获取模版列中按钮事件所在行的关键字                        
<asp:Label ID="Lblqx1" runat="server"></asp:Label>
获取模版列中按钮事件所在行的关键字                        
<asp:Button ID="BtnGjl" runat="server" Text="设置" CommandArgument='<%#Eval("id") %>'  CommandName="gjl" />
获取模版列中按钮事件所在行的关键字                    
</ItemTemplate>
获取模版列中按钮事件所在行的关键字                
</asp:TemplateField>
获取模版列中按钮事件所在行的关键字            
</Columns>
获取模版列中按钮事件所在行的关键字        
</asp:GridView>

 2 后台cs的GridView1_RowCommand方法

获取模版列中按钮事件所在行的关键字    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    }

相关文章:

  • 2022-12-23
  • 2021-06-05
  • 2021-09-14
  • 2021-07-17
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-17
  • 2021-09-21
  • 2021-09-15
  • 2021-07-17
  • 2022-12-23
相关资源
相似解决方案