I have a Gridview in my page Which I can Select each row i want by using checkbox when i
select a row in Gridview and click on Delete button igot this error “Must declare the scalar variable “@Senduserid” “
here’s the Delete button code
protected void btnMultipleRowDelete_Click(object sender, EventArgs e)
{
// Looping through all the rows in the GridView
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox checkbox = (CheckBox)row.FindControl("chkRows");
//Check if the checkbox is checked.
//value in the CheckBox's Value property is set as the //value of the delete command's parameter.
while (checkbox.Checked)
{
// Retreive the ID
int ida = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
// Pass the value of the selected Employye ID to the Delete
//These numbers indicate in which order tables shoulde be deleted
/*1*/
new BLL.LoginBLL().Delete(ida);
/*2*/
new BLL.MessageBLL().Delete(ida);
/*3*/
new BLL.JointBLL().Delete(ida);
/*4*/
new BLL.Tempprice().Delete(ida);
/*5*/
new BLL.LotsBLL().Delete(ida);
/*6*/
new BLL.AuctionBLL().Delete(ida);
/*7*/
new BLL.ProfileBLL().DeleteProfile(ida);
checkbox.Checked = false;
}
//refresh the Gridview rows
ShowUsers();
}
}
And code of the place I got this error:`
public bool Delete(int Id)
{
using (SqlCommand cmd = new SqlCommand())
{
string text = string.Format("Delete From {0} where {1} = @{1} or {2} =@{2}"
, Common.Data.MessageInfo.TableName
, Common.Data.MessageInfo.SenduseridField
,Common.Data.MessageInfo.RecuseridField);
cmd.CommandText = text;
SqlParameter param = new SqlParameter("@" + Common.Data.MessageInfo.SenduseridField, Id);
param.SqlDbType = SqlDbType.Int;
param = new SqlParameter("@" + Common.Data.MessageInfo.RecuseridField, Id);
param.SqlDbType = SqlDbType.Int;
cmd.Parameters.Add(param);
cmd.Connection = this.GetConnection();
cmd.Connection.Open();
cmd.ExecuteNonQuery();
return true;
}
}
DataBase Relationship

You instantiate two parameters, but you don’t add the first parameter to the command. Before you instantiate the recuseridfield parameter, add the senduseridfield parameter to the command’s parameter list.