如何在GridView中删除选定的行 [英] How to delete a selected row in gridview
本文介绍了如何在GridView中删除选定的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在gridview中删除选定的行
请帮助这里是我的.aspx控件
How to delete a selected row in gridview
pls help here is my .aspx control
<asp:GridView ID="GridView1" runat="server" Width="100%" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Width="5%" />
<asp:Label ID="Label1" runat="server" Text="Subject"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" Width="5%" />
<asp:LinkButton ID="LinkButton1" Text='<%#Eval("md_subject") %>' runat="server" Width="70%">LinkButton</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
推荐答案
这里是一个示例方法:
将此标签添加到您的ItemTemplate
部分:
Here is a sample approach :
Add this tag to yourItemTemplate
section :
<asp:imagebutton id="ibDelete" runat="server" commandname="Delete" imageurl="images/del.gif" xmlns:asp="#unknown" />
并记住您的gridview DataSource
应该支持Delete
操作.这是一个示例数据源:
and remember that your gridview DataSource
should support Delete
operation. Here is a sample datasource :
<asp:sqldatasource id="sdsCountry" runat="server" xmlns:asp="#unknown">
ConnectionString="<%
ConnectionStrings:GConnectionString%>" DeleteCommand ="DELETE FROM [Country] WHERE [ID] = @original_ID"> < 删除参数 > < asp:parameters 名称 =" 类型 Int32 " / < /deleteparameters > < /asp:sqldatasource >
ConnectionStrings:GConnectionString %>" DeleteCommand="DELETE FROM [Country] WHERE [ID] = @original_ID"> <deleteparameters> <asp:parameter name="original_ID" type="Int32" /> </deleteparameters> </asp:sqldatasource>
很明显,Visual Studio将通过向导帮助您创建一个DataSource
,该DataSource
支持所有CRUD(创建,读取,更新,删除)操作.
Its clear that the Visual Studio will help you by its wizard to create a DataSource
which supports all CRUD(Create, Read, Update, Delete) operations.
这篇关于如何在GridView中删除选定的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文