Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6967715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:21:27+00:00 2026-05-27T16:21:27+00:00

I have a Gridview in my page Which I can Select each row i

  • 0

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

DataBase Relationship

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:21:28+00:00Added an answer on May 27, 2026 at 4:21 pm

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GridView which you can click on a row and it should
I have a GridView on my page. I want to set a cell click
I have a page on which I've thrown a LinqDataSource and a GridView. I've
I have a GridView control on an ASP page, which I've bound to a
So I have an ASP.NET page with two controls: a GridView which displays rows
I have a GridView which is continually rebound using a timer and is within
I have a script which loops through a GridView on my web page, and
I have an ASP.NET 4.0 home page which displays about 20 product listings. Each
I have a page which has a GridView on it, which is populated from
I have a gridview which can be filtered from one or more values in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.