Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to delete a selected row in gridview
pls help here is my .aspx control

XML
<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>
Posted

1 solution

Here is a sample approach :
Add this tag to your ItemTemplate section :

ASP.NET
<asp:imagebutton id="ibDelete" runat="server" commandname="Delete" imageurl="images/del.gif" xmlns:asp="#unknown" />


and remember that your gridview DataSource should support Delete operation. Here is a sample datasource :

ASP.NET
<asp:sqldatasource id="sdsCountry" runat="server" xmlns:asp="#unknown">
        ConnectionString="<%$ ConnectionStrings:GConnectionString %>" 
        DeleteCommand="DELETE FROM [Country] WHERE [ID] = @original_ID"> 
       <deleteparameters>
            <asp:parameter name="original_ID" type="Int32" />
        </deleteparameters>
</asp:sqldatasource>


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.
 
Share this answer
 
Comments
sabva yogesh 4-Dec-12 5:24am    
How to Delete selected row in GridView?
plz help me my quetion sollution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900