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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:43:12+00:00 2026-05-21T17:43:12+00:00

Step 1:- Click on more Step 2:- Click on add to cart to add

  • 0

Step 1:- Click on more
enter image description here

Step 2:- Click on add to cart to add an item to cart
enter image description here

This is my gridview

<asp:GridView ID="GridView1" runat="server" 
                                                   AllowSorting="True" 
                                                   AutoGenerateColumns="False" 
                                                   CellPadding="4"      
                                                   ForeColor="#333333" 
                                                   GridLines="None" 
                                                   Width="810px" 
                                                   CssClass="gridview"                               
                                                   DataSourceID="SqlDataSource3" >
                      <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                      <Columns>
                      <asp:TemplateField ShowHeader="False">
                            <ItemTemplate>
                                <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit">More...</asp:LinkButton>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:LinkButton ID="GVAddToCart" runat="server" onclick="GVAddToCart_Click">Add to cart</asp:LinkButton>
                            </EditItemTemplate>
                      </asp:TemplateField>
                    <asp:TemplateField HeaderText="itemName" SortExpression="itemName">
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("itemName") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:Label ID="itemName" runat="server" Text='<%# Eval("itemName") %>'></asp:Label>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="price" SortExpression="price">
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("price") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:Label ID="price" runat="server" Text='<%# Eval("price") %>'></asp:Label>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="offer" SortExpression="offer">
                        <ItemTemplate>
                            <asp:Label ID="Label3" runat="server" Text='<%# Bind("offer") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:Label ID="offer" runat="server" Text='<%# Eval("offer") %>'></asp:Label>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="availability" SortExpression="availability">
                        <ItemTemplate>
                            <asp:Label ID="Label4" runat="server" Text='<%# Bind("availability") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:Label ID="availability" runat="server" Text='<%# Eval("availability") %>'></asp:Label>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="shopName" SortExpression="shopName">
                        <ItemTemplate>
                            <asp:Label ID="Label5" runat="server" Text='<%# Bind("shopName") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:Label ID="shopName" runat="server" Text='<%# Eval("shopName") %>'></asp:Label>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="address" SortExpression="address">
                        <ItemTemplate>
                            <asp:Label ID="Label6" runat="server" Text='<%# Bind("address") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:Label ID="address" runat="server" Text='<%# Eval("address") %>'></asp:Label>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="email" SortExpression="email">
                        <ItemTemplate>
                            <asp:Label ID="Label7" runat="server" Text='<%# Bind("email") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:Label ID="email" runat="server" Text='<%# Eval("email") %>'></asp:Label>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="phone" SortExpression="phone">
                        <ItemTemplate>
                            <asp:Label ID="Label8" runat="server" Text='<%# Bind("phone") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:Label ID="phone" runat="server" Text='<%# Eval("phone") %>'></asp:Label>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    </Columns>
    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
    <EditRowStyle BackColor="#999999" />
    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    </asp:GridView>

    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                                           ConnectionString="<%$ ConnectionStrings:databaseConnectionString %>" 
                                           SelectCommand="SELECT shopList.itemName, shopList.offer, shopList.price, shopList.availability, shopDescription.shopName, shopDescription.address, shopDescription.email, shopDescription.phone FROM shopList INNER JOIN shopDescription ON shopList.shopID = shopDescription.shopID">
    </asp:SqlDataSource>

This is the code behind for the add to cart link button

Protected Sub GVAddToCart_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If User.Identity.Name = "" Then
            MsgBox("You need to login first before adding anything to the cart!", , "")
            Response.Redirect("~/login.aspx", True)
            Exit Sub
        End If

        Dim sCart = New cart
        Dim itemName, GVPrice, offer As Label
        Dim userID, buyNo, itemID As String

        itemID = Request.QueryString("itemID")
        itemName = CType(ListView1.Items(0).FindControl("itemName"), Label)
        userID = User.Identity.Name

        Dim index As Integer = GridView1.EditIndex
        GVPrice = CType(GridView1.Rows(index).FindControl("price"), Label)
        GVPrice.Text = CType(GVPrice.Text, Integer)
        offer = CType(GridView1.Rows(index).FindControl("offer"), Label)

        If sCart.CheckIfItemPresent(userID, itemID, GVPrice.Text, offer.Text) = True Then
            Exit Sub
        End If

        buyNo = sCart.findLatestBuyNo(userID)
        Session("buyNo") = buyNo

        Session("buyNo") = sCart.AddToCart(itemID, itemName.Text, GVPrice.Text, offer.Text, buyNo, userID)
    End Sub

So what I want to do is to remove the Step 1..how can i do this?

If i remove the more link..it stops working…please help me.

I have to click on the more link to to get the Add to cart link…I want to add an item to the cart in one click..with what i have now …I need two clicks.

When I click on more it goes to edit mode..then when I click on add to cart(which is in edit template)..it takes the price and offer values from the edit template..if i move the “Add To Cart” button into the ItemTemplate…it cant access the offer and price values. If i move the “Add To Cart” button into the ItemTemplate how will I know which row is being clicked?

  • 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-21T17:43:12+00:00Added an answer on May 21, 2026 at 5:43 pm

    By your description “Remove The Step 1”, it sounds like you want that link/button field shown as Add To Cart all the time.

    Suggest creating a ButtonField instead of your ItemTemplates and EditItemTemplates. It appears you don’t need editing capability, but rather just a way to access those properties on the row.

     <asp:GridView OnRowCommand="GridView_RowCommand">
    
         <asp:ButtonField buttontype="Link" 
                          commandname="Add" 
                          text="Add to Cart"/>
    
          <asp:BoundField datafield="itemName" headertext="Item"/>
          <asp:BoundField datafield="itemPrice" headertext="Your Price"/>
          <asp:BoundField datafield="shopName" headertext="Shop Name"/>
          ..... etc.
    

    Your code-behind would need to be changed like so:

      Sub GridView_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
    
        If e.CommandName = "Add" Then      
          Dim index As Integer = Convert.ToInt32(e.CommandArgument)
          Dim row As GridViewRow = GridView1.Rows(index)
    
          Dim itemName As String = Server.HtmlDecode(row.Cells(1).Text) 
          Dim itemPrice As String = Server.HtmlDecode(row.Cells(2).Text) 
          '...... etc
          'All required business logic to add to cart.
        End If
    
      End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When you click, Add to Bag on this page, it freezes IE6 every time.
I have a multi-step order form built in this manner: Step 1: Choose category
Can someone explain step by step how this query is processed? SELECT F.ID, F.FirstName,
This is my first step to programming.guys your help hands required.I watched youtube video
Why does the following step pass: page.has_css?(doesnt exist) when this correctly fails: page.should have_css(doesnt
I am learning AJAX in zend framework step by step. I use this question
I try using Devexpress Layout-Control (For costume usage). So I want add all item's
This is more of a theoretical question rather than language specific, but I'm mostly
question marks are hard to search for in google. What does this mean step
I was thinking that, if we add this attribute to a element's onlick event

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.