GridView模板列如何给button绑定数据 然后按用这个button传送ID?
2008-10-06 16:07
- HTML code
-
<asp:TemplateField> <ItemTemplate> <asp:Button ID="Button2" runat="server" CommandArgument='<%# Eval("ID") %>' oncommand="Button2_Command" Text="删除" OnClientClick="return confirm('确定要删除该列吗?')"/> </ItemTemplate> </asp:TemplateField>
- C# code
-
protected void Button2_Command(object sender, CommandEventArgs e) { if (e.CommandArgument.ToString() != "")//ID { //... } }
|