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 6225865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:55:22+00:00 2026-05-24T08:55:22+00:00

I.e. I have a piece of code on my page as follows, which is

  • 0

I.e. I have a piece of code on my page as follows, which is in page_load

Dim subTotal As Integer = 0
    For Each item As CartItem In ShoppingCart.Instance.Items
        subTotal += 1
    Next

    strShoppingCart.Append(subTotal).Append(" Items")
    shoppingCartItems.Text = strShoppingCart.ToString()

And I can then add items to my cart as follows

Protected Sub Update_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim rowscount As Integer = productListTable.Rows.Count

    For Each row As GridViewRow In productListTable.Rows
        If row.RowType = DataControlRowType.DataRow Then
            ' We'll use a try catch block in case something other than a number is typed in. If so, we'll just ignore it.
            Try
                ' Get the productId from the GridView's datakeys
                Dim productId = Convert.ToInt32(productListTable.DataKeys(row.RowIndex).Value)
                ' Find the quantity TextBox and retrieve the value
                Dim quantity = Integer.Parse(CType(row.Cells(1).FindControl("txtQuantity"), TextBox).Text)
                'Dim price = Decimal.Parse(CType(row.Cells(1).FindControl("TradePriceField"), Label).Text)
                Dim price = Decimal.Parse("16.00")
                Dim productName = CType(row.Cells(1).FindControl("ProductNameField"), Label).Text
                Dim packSize = Integer.Parse(CType(row.Cells(1).FindControl("PackSizeField"), Label).Text)
                Dim stockIndicator = Integer.Parse(CType(row.Cells(1).FindControl("PackSizeField"), Label).Text)
                ShoppingCart.Instance.AddItem(productId, quantity, price, productName, packSize, stockIndicator)


            Catch ex As FormatException

            End Try
        End If
    Next
End Sub

The problem is as follows

Page Load
Items Count is 0

I add a product the page still says 0 Items when there is actually 1 item in session
I refresh the page the counter goes to one

How can I to read from correct session count ?

  • 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-24T08:55:24+00:00Added an answer on May 24, 2026 at 8:55 am

    Page_Load is going to fire before Update_Click, which is why you’re not seeing the count increase after the initial form submit. You’ll need to either update the shoppingCartItems control after Update_Click executes, or you can Response.Redirect back to the page to get the display to update. I personally like to use Response.Redirect after a post because if the user refreshes the page then you won’t see that browser message that says it is going to repost the data.

    You also might want to check out the ASP.NET Page Life Cycle.

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

Sidebar

Related Questions

My problem is as it follows: I have a piece of JavaScript code which
I have this piece of code: Page.ClientScript.RegisterClientScriptInclude(this.GetType(), Guid.NewGuid().ToString(), this.ResolveUrl(~/Scripts/min.js)); When we push to our
I have the following piece of code in my web page. After the method
I have a piece of jQuery code that fills an element on the page
I have a Login.aspx page, and I wanna incude some piece of code in
I have piece of javascript code, which should process when the browser window is
I have time-critical piece of code in my app. I made the thread which
I have this piece of code in my page <body onmouseup=fun()> ....... ....... <button
I have a piece of code that returns a web page using the built-in
I have setup globalization on my web page and have this piece of code

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.