GridView如何写按钮事件删除指定行ASP.NET(C#)
<asp:GridViewID="GridView1"runat="server"AutoGenerateColumns="False"onrowdeleted="Gri...
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
onrowdeleted="GridView1_RowDeleted">
<Columns>
<asp:TemplateField HeaderText="产品名称">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("images") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="删除产品" ShowHeader="False">
<ItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="false" CommandArgument='<%# Bind("id") %>'
Text="删除" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
前台怎么改?后台怎么写点击事件呢?
thank you!
我加了个onrowcommand="GridView1_RowCommand"
后台用了 int rowid = Int32.Parse(e.CommandArgument.ToString());//获取点击了第几行 展开
onrowdeleted="GridView1_RowDeleted">
<Columns>
<asp:TemplateField HeaderText="产品名称">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("images") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="删除产品" ShowHeader="False">
<ItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="false" CommandArgument='<%# Bind("id") %>'
Text="删除" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
前台怎么改?后台怎么写点击事件呢?
thank you!
我加了个onrowcommand="GridView1_RowCommand"
后台用了 int rowid = Int32.Parse(e.CommandArgument.ToString());//获取点击了第几行 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询