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 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Dilip GuptaRank #2,085 · 690 reputationPosted Nov 29, 2016, 2:17 AM EST