Click here to Skip to main content
12,560,241 members (60,487 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET C#4.0
hi all
How to delete a row in a gridview with a delete button, with Confirmation. the gridview has no data bound values.
the values are from a text box.
i had set the delete button with button option provided in the gridview itself.

can any help me with the code

thanks in advance
Posted 4-Jun-12 23:12pm
Ragi Gopi1.3K
Sandeep Mewara 5-Jun-12 5:21am
And did you try to do it? Where are you stuck?
Ragi Gopi 5-Jun-12 6:02am
i used the following code
but it is generating error
protected void gv1_RowDeleting(object sender, GridViewDeleteEventArgs e)
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

U can see a post in Code project itself which will let you do that deletion easily, Just refer this-

GridView Delete, with Confirmation[^]
Ragi Gopi 5-Jun-12 5:20am
i have no connection with database
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

you can add a template field to your grid view and in that add a link button with command argument attribute and set the value to the item ID or KeyName, and then in RowCommand of grid, use this code:
int id = Convert.ToInt32(e.CommandArgument);
its realy base on your data access logic to how to handle the delete event!
for me I use linq to EF and just call the deleteObject method.

for confirmation use onclientclick attribute and use this code:
<asp:LinkButton ID="LinkButton1" OnClientClick="confirm(are you sure to delete this record"
 CommandArgument='<%#Eval("id") %>' runat="server">delete</asp:LinkButton>
Rate this: bad
Please Sign up or sign in to vote.

Solution 4


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.161026.1 | Last Updated 29 Mar 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100