Click here to Skip to main content
13,504,548 members
Rate this:
Please Sign up or sign in to vote.
See more:
how to delete row delete in grid view ( backend my sql
Posted 23-Jan-13 23:08pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

protected void lnkdelete_Click(object sender, EventArgs e)

LinkButton lnkbtn= sender as LinkButton;
//getting particular row linkbutton
GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
//getting userid of particular row
int userid = Convert.ToInt32(gvrecords.DataKeys[gvrow.RowIndex].Value.ToString());
string username = gvrow.Cells[0].Text;
SqlCommand cmd = new SqlCommand("delete from UserDetails where UserId="+userid,con);
int result=cmd.ExecuteNonQuery();
if (result == 1)
//Displaying alert message after successfully deletion of user
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert('" + username + " details deleted successfully')", true);


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 |
Web04 | 2.8.180417.1 | Last Updated 24 Jan 2013
Copyright © CodeProject, 1999-2018
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