关于GridView中按钮的commandargument使用
2008年03月03日 星期一 21:07
当你不知道当前点击的是第几行,可以用以下方法实现要求:
<ItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument=' <%# Eval("field1") %> ' CommandName="play" Text=' <%# Eval("field2") %> '> </asp:LinkButton> </ItemTemplate> 上面这个LinkButton,Text绑定了字段2, CommandArgument绑定了字段1 那么, protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { LinkButton lb = (LinkButton)e.CommandSource; string a = lb.Text;//这里可以获得点击行字段field2的值 string b = e.CommandArgument;//这里可以获得点击行字段field1的值 |
转载于:https://blog.51cto.com/447118/208857