Click here to Skip to main content
15,920,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have to put checkbox in gridview for delete row.Delete rows where i have checked checkbox.
how to do this without using templatefield,iteamtemplate.
Is there any way to do this?
Richard C Bishop 24-Apr-13 11:42am    
No, there is not way to do this without using a templated field.

1 solution


Take a look into the below code.

<asp:GridView ID="gvmails" runat="server" AutoGenerateColumns="false">
               <asp:TemplateField HeaderText="Select">
                       <asp:CheckBox ID="chkSelect" runat="server" />
               <asp:TemplateField HeaderText="Column 1">
                       <asp:Label ID="lblColumn1" runat="server" Text='<%# Eval("Column1") %>'></asp:Label>
               <asp:TemplateField HeaderText="Column 2">
                       <asp:Label ID="lblColumn2" runat="server" Text='<%# Eval("Column2") %>'></asp:Label>

In OnSelectedIndexChanged event of checkbox write the code to delete a record. By using CommandArgument of checkbox you can get the record id to be deleted from gridview.

Hope this will solve your problem.

Share this answer

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