if (e.CommandName.Equals("Delete")) { int index = Convert.ToInt32(e.CommandArgument); var id = ((Label)GridView1.Rows[index].Cells[0].FindControl("lblid")).Text.Trim(); // execption on this line SqlConnection con = new SqlConnection(connstring); string qry = "Delete from ['ISB VAS Nodes$'] where ID = " + id + ""; SqlCommand com = new SqlCommand(qry, con); // open connection con.Open(); int numberDeleted = com.ExecuteNonQuery(); if (numberDeleted > 0) { Label2.Text = "Deleted"; binddata(); } else { Label2.Text = "Not Deleted"; } // close connection con.Close(); }
GrieViewRow row = (GridViewRow)((LinkButton)e.CommandSource).Parent.Parent; var id = ((Label)row.FindControl("lblid")).Text.Trim();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)