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

  • SEARCH
  • Home
  • 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 7949165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:55:03+00:00 2026-06-04T01:55:03+00:00

From this link: asp.net grid view bulk updating all cells I did the following:

  • 0

From this link:

asp.net grid view bulk updating all cells

I did the following:

 protected void ButtonUpdate_Click(object sender, EventArgs e)
    {
       // foreach (GridViewRow row in GridView1.Rows)

       // {

        int RowIndex = 0;
        GridViewRow row = (GridViewRow)GridView1.Rows[RowIndex];

            Int32 intresortID = Convert.ToInt32(Request.QueryString["TypeID"]);
            Label dtm = row.FindControl("Label1") as Label;
            Label strRoomType = row.FindControl("strRoomTypeLabel") as Label;
            Label strDescription = row.FindControl("Label3") as Label;
            TextBox Qty = row.FindControl("intQtyTextBox") as TextBox;
            TextBox Price = row.FindControl("curPriceTextBox") as TextBox;
            Label intWSCode = row.FindControl("intWSCodeLabel") as Label;

            string connStr = ConfigurationManager.ConnectionStrings["bedbankstandssConnectionString"].ConnectionString;
            SqlConnection Con = new SqlConnection(connStr);
            SqlCommand cmd = new SqlCommand("Update tblAvailable set intqty=@intQty, curprice=@curprice where intresortid=@intresortid and dtm=@dtm and strroomtype=@strroomtype",Con);


            //SqlParameter ddtm= new SqlParameter("@dtm",dtm) ;
            //SqlParameter sstrRoomType = new SqlParameter("@strroomtype", strRoomType);
            //SqlParameter qQty = new SqlParameter("@intQty", Qty);
            //SqlParameter pPrice =new SqlParameter("@curPrice",Price);
            //SqlParameter resortID = new SqlParameter("@intResortID", intresortID);
            cmd.Parameters.AddWithValue("@dtm",dtm.Text.Trim());
            cmd.Parameters.AddWithValue("@strroomtype",strRoomType.Text.Trim());
            cmd.Parameters.AddWithValue("@intQty", Qty.Text.Trim());
            cmd.Parameters.AddWithValue("@curPrice",Price.Text.Trim());
            cmd.Parameters.AddWithValue("@intResortID",intresortID);
            Con.Open();
            cmd.ExecuteNonQuery();
            GridView1.EditIndex = -1;
            DataBind();





       // }
    }

But only one row gets updated, the first one.

Would somebody be able to tell me where I went wrong please.

  • 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-06-04T01:55:04+00:00Added an answer on June 4, 2026 at 1:55 am

    You have commented out the loop, so why are you wondering that only one row is updated?

    foreach (GridViewRow row in GridView1.Rows)
    {
        // ...
    }
    

    Apart from that, use the using-statement for your SqlConnection and SqlCommand to ensure that is gets disposed/closed.

    using(SqlConnection Con = new SqlConnection(connStr))
    {
        using(SqlCommand cmd = new SqlCommand("Update tblAvailable set intqty=@intQty, curprice=@curprice where intresortid=@intresortid and dtm=@dtm and strroomtype=@strroomtype",Con))
        {
            // ...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently downloaded an event calendar from this link: http://www.asp.net/downloads/starter-kits/club/EventCalendar.zip I want to use
I'm following Steve Sanderson's example from this ASP.NET MVC book on creating a model
I have borrowed code from this link PHP regex templating - find all occurrences
I upgrade my magento store 1.4.1.1 to 1.6.1.0 following instruction from this link .
following this link i was able to load and read pixels from a .gif.
I'm implementing the session sharing structure from this link for an ASP classic site
I am working on an ASP.NET project where we are updating all of our
i have a regular html Grid and i am binding my asp.net mvc view
I am trying to add a jqGrid to a ASP.NET MVC3 partial view. This
I have an ASP.NET GridView which is populated from a SQL Server database. This

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.