且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在GridView中删除选定的行

更新时间:2023-12-05 11:10:52

这里是一个示例方法:
将此标签添加到您的ItemTemplate部分:

Here is a sample approach :
Add this tag to your ItemTemplate 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.