我在执行下面的delete操作时出现图片上的错误,请各位指点指点.
protected void Gv_userlist_RowDeleting(object sender, GridViewDeleteEventArgs e)
{//删除
string st_sqlstr = "delete from Users where User_id=@userid";
SqlCommand st_comm = new SqlCommand(st_sqlstr, conn);
st_comm.Parameters.Add(new SqlParameter("@userid", SqlDbType.VarChar, 50));
//st_comm.Parameters["@userid"].Value = st_dtg_userinformation.DataKeys[(int)e.Item.ItemIndex];
//st_comm.Parameters["@userid"].Value = Gv_userlist.DataKeys[(int)e.RowIndex].ToString();//debug
st_comm.Parameters["@userid"].Value=Gv_userlist.DataKeys[(int)e.RowIndex].Values[0].ToString();
st_comm.Connection.Open();
try
{
st_comm.ExecuteNonQuery();
Lbl_note.Text = "删除成功";
}
catch (SqlException)
{
Lbl_note.Text = "删除失败";
Lbl_note.Style["color"] = "red";
}
st_comm.Connection.Close();
St_BindGridView();
}