I want to delete selected record but it is giving me
error--System.Web.HttpException: 'DataBinding: 'System.Data.DataRowView'
does not contain a property with the name 'Id'.'
CommandName="Deleterow" />
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Deleterow")
{
string id = e.CommandArgument.ToString();
string constr = ConfigurationManager.ConnectionStrings["Q_SS_regnConnectionString1"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand sq = new SqlCommand("DELETE FROM Booking where Id='" + id + "'", con);
sq.ExecuteNonQuery();
con.Close();
}
}
{
if (e.CommandName == "Deleterow")
{
string id = e.CommandArgument.ToString();
string constr = ConfigurationManager.ConnectionStrings["Q_SS_regnConnectionString1"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand sq = new SqlCommand("DELETE FROM Booking where Id='" + id + "'", con);
sq.ExecuteNonQuery();
con.Close();
}
}
Tamil SelvanPosted Oct 3, 2019, 12:03 AM
ItsmePosted Oct 1, 2019, 5:35 AM
CommandName="Deleterow" />
Tamil SelvanPosted Oct 1, 2019, 5:08 AM
{
string constr = ConfigurationManager.ConnectionStrings["Q_SS_regnConnectionString1"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand sq = new SqlCommand("DELETE FROM Booking where Id='" + id + "'", con);
sq.ExecuteNonQuery();
con.Close();
}