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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:25:03+00:00 2026-05-24T07:25:03+00:00

Hey I am building a shop (without payment) i.e. 1) Select Products 2) Checkout

  • 0

Hey I am building a shop (without payment)

i.e.

1) Select Products
2) Checkout
3) Confirmation

The selecting products screen will look like a gridview which will display

name price quantity
Text Text Input box

So i.e. lets say I have 10 products per page so i.e. 10 quantity input boxes per gridview.

And then I have 2 Buttons below my gridview i.e. Update and Checkout.

Just even worrying about Update for now.

How could that work i.e. would I have to check every input box in gridview for which a value was entered ?

I.e. is there any example how I can loop through gridview row check for a value which is greater than 0 or null for example and if there is a value then perform a function like

ShoppingCart.Instance.AddItem(5, 5)

enter image description here

My Gridview Code at the moment

<asp:GridView ID="productListTable" runat="server" DataSourceID="srcProductListPerCustomer" AutoGenerateColumns="False" AlternatingRowStyle-CssClass="tr_dark"  HeaderStyle-CssClass="header_req" BorderWidth="0px" GridLines="None" AllowPaging="true" PageSize="25" EmptyDataText="No records." AllowSorting="true" Width="100%">         
    <Columns>                         
            <asp:TemplateField HeaderText="Product Name" HeaderStyle-Width="130px" SortExpression="productName">
                <ItemTemplate>   
                <asp:Label ID="ProductNameField" runat="server" Text='<%# Eval("productName").ToString() %>'></asp:Label>
                </ItemTemplate>                     
            </asp:TemplateField> 

    </Columns>
    <Columns>                         
            <asp:TemplateField HeaderText="Pack Size" HeaderStyle-Width="70px" SortExpression="packSize">
                <ItemTemplate>  
                <asp:Label ID="PackSizeField" runat="server" Text='<%#  Eval("packSize").ToString()%>'></asp:Label>
                </ItemTemplate>                     
            </asp:TemplateField> 

    </Columns>
    <Columns>                         
            <asp:TemplateField HeaderText="Trade Price" HeaderStyle-Width="130px" SortExpression="address">
                <ItemTemplate>   
                <asp:Label ID="TradePriceField" runat="server" Text='<%#  DisplayMoney(Eval("tradePrice").ToString())%>'></asp:Label>
                </ItemTemplate>                     
            </asp:TemplateField> 

    </Columns>
    <Columns>                         
            <asp:TemplateField HeaderText="Discount" HeaderStyle-Width="60px" SortExpression="discount">
                <ItemTemplate>   
                <asp:Label ID="DiscountField" runat="server" Text='<%# Eval("discount").ToString() %>'></asp:Label>
                </ItemTemplate>                     
            </asp:TemplateField> 

    </Columns>
    <Columns>                         
            <asp:TemplateField HeaderText="Actual Price" HeaderStyle-Width="130px" SortExpression="actualPrice">
                <ItemTemplate>   
                <asp:Label ID="ActualPriceField" runat="server" Text=''></asp:Label>
                </ItemTemplate>                     
            </asp:TemplateField> 

    </Columns>
    <Columns>                         
            <asp:TemplateField HeaderText="Stock" HeaderStyle-Width="130px" SortExpression="stock_indicator">
                <ItemTemplate>   
                <asp:Label ID="StockField" runat="server" Text='<%# DisplayStockLevel(Eval("stock_indicator").ToString()) %>'></asp:Label>
                </ItemTemplate>                     
            </asp:TemplateField> 

    </Columns>
     <Columns>  

    <asp:TemplateField HeaderText="Quantity">
                    <ItemTemplate>
                        <asp:TextBox runat="server" ID="txtQuantity" Columns="5"></asp:TextBox><br />
                        <asp:LinkButton runat="server" ID="btnRemove" Text="Remove" CommandName="Remove" CommandArgument='<%# Eval("product_ID_key") %>' style="font-size:12px;"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
    </Columns>
    <HeaderStyle CssClass="header_req" />
    <AlternatingRowStyle CssClass="tr_dark" />
    <PagerStyle CssClass="pagination" />
    <PagerSettings PageButtonCount="3" FirstPageText="First" LastPageText="Last" NextPageText="Next" PreviousPageText="Previous" Mode="NumericFirstLast" />      
</asp:GridView>
  • 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-24T07:25:03+00:00Added an answer on May 24, 2026 at 7:25 am

    Place this code in your button click event to iterate through each row of your productList GridView and call ShoppingCart.Instance.AddItem(productId, qty) or any other method you want, to update the product list and their quantities:

    For i As Integer = 0 To Me.productListTable.Rows.Count - 1
                Dim txtQuantity As TextBox = CType(productListTable.Rows(i).FindControl("txtQuantity"), TextBox)
                If Not txtQuantity Is Nothing Then
                    Dim qty As Integer = 0
                    If txtQuantity.Text.Trim() <> String.Empty Then
                        qty = Integer.Parse(txtQuantity.Text.Trim())
    
                        'get unique id of product - it can be SKU code or whatever that is unique for every product
                        Dim productId As String = productListTable.DataKeys(i).Value
    
                        'Update product list and quantities
                        ShoppingCart.Instance.AddItem(productId, 5)
                    End If
                End If
            Next
    

    If you have noticed in ShoppingCart.Instance.AddItem method, there is a product Id I am passing so in code we update the correct item, in order to retrieve this unique key, you need to add DataKeyName property in your GridView tags with value equals to the name of unique key… e.g.: DataKeyNames=”ProductId”

    <asp:GridView ID="productListTable" runat="server" DataSourceID="srcProductListPerCustomer" DataKeyNames="ProductId"
            AutoGenerateColumns="False" AlternatingRowStyle-CssClass="tr_dark" HeaderStyle-CssClass="header_req"
            BorderWidth="0px" GridLines="None" AllowPaging="true" PageSize="25" EmptyDataText="No records."
            AllowSorting="true" Width="100%">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building something like Facebooks Wall inside of Rails. It will look something like
Hey so I'm building an iOS app. The fist window is a login screen
Hey I'm building an app that will allow a user to log into a
hey guys so im building an application and one of teh features it will
Hey all, I would like some advice from the programming community. I am building
Hey. We're building a large ASP.NET website, and have hired an external firm to
Hey guys. I'm building a simple blog and have my data returning from my
EDIT: This problem has been solved. See below. Hey all. I'm building an iPhone
Hey all, I've been building an app for a client and part of it
Hey. I urgently need some help on building up a complete table using VBA.

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.