I use this below code in .aspx file for delete Girdview row.
Asp Code:
C# Code
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(e.CommandName == "DeleteRow")
{
SqlConnection cs = new SqlConnection("Data Source=DESKTOP-3T94FQ0;Initial Catalog=RAMS;Integrated Security=False;UID=sa;Password=sa123;");
SqlCommand deleteCommand = new SqlCommand("DELETE FROM [tbl_musannet] WHERE [mus_id]= @mus_id",cs);
deleteCommand.Parameters.Add("@mus_id", SqlDbType.BigInt).Value = Convert.ToInt64(e.CommandName);
cs.Open();
deleteCommand.ExecuteNonQuery();
cs.Close();
}
}
But when I going to delete rows "Input string was not in a correct format" error is showing.
Please help.
Thanks
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Dilip GuptaPosted Nov 29, 2016, 7:17 AM