Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Adding Items To Cart

Adding Items To Cart

Scheduled Pinned Locked Moved ASP.NET
c++helptutorial
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kjosh
    wrote on last edited by
    #1

    Hi, Iam implementing shoppingcart.In that i placed a Gridview with columns Name,price,picture,checkboxfield(select). User select the items from the gridview and click on ADDCART Button which is outside of GridView. when user click ADDCART button,the rows in the gridview for which checkbox field checked that vales iam storing in a datatable. for this ADDCART button click event i wrote the following code: int c=0; for (int i = 0; i < GridView1.Rows.Count; i++) { GridViewRow row = GridView1.Rows[i]; bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked; if (isChecked) c++; } Response.Write(c.ToString()); //This code only to check. Eventhough i checked 2 checkbox fields,and click on ADDCART The c value is 0. Anything wrong in the above code. Or Give me some idea on How to ADD user selected items to CART. Please help me. Thanks in advance

    N T N 3 Replies Last reply
    0
    • K kjosh

      Hi, Iam implementing shoppingcart.In that i placed a Gridview with columns Name,price,picture,checkboxfield(select). User select the items from the gridview and click on ADDCART Button which is outside of GridView. when user click ADDCART button,the rows in the gridview for which checkbox field checked that vales iam storing in a datatable. for this ADDCART button click event i wrote the following code: int c=0; for (int i = 0; i < GridView1.Rows.Count; i++) { GridViewRow row = GridView1.Rows[i]; bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked; if (isChecked) c++; } Response.Write(c.ToString()); //This code only to check. Eventhough i checked 2 checkbox fields,and click on ADDCART The c value is 0. Anything wrong in the above code. Or Give me some idea on How to ADD user selected items to CART. Please help me. Thanks in advance

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      This might give you some help, look at the Checkboxes and TextBoxes section. http://www.codeproject.com/aspnet/datagriddemo.asp[^]

      only two letters away from being an asset

      1 Reply Last reply
      0
      • K kjosh

        Hi, Iam implementing shoppingcart.In that i placed a Gridview with columns Name,price,picture,checkboxfield(select). User select the items from the gridview and click on ADDCART Button which is outside of GridView. when user click ADDCART button,the rows in the gridview for which checkbox field checked that vales iam storing in a datatable. for this ADDCART button click event i wrote the following code: int c=0; for (int i = 0; i < GridView1.Rows.Count; i++) { GridViewRow row = GridView1.Rows[i]; bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked; if (isChecked) c++; } Response.Write(c.ToString()); //This code only to check. Eventhough i checked 2 checkbox fields,and click on ADDCART The c value is 0. Anything wrong in the above code. Or Give me some idea on How to ADD user selected items to CART. Please help me. Thanks in advance

        T Offline
        T Offline
        Tim Kohler
        wrote on last edited by
        #3

        Are you manually binding the items to the gridview (i.e. not using a datasourcecontrol)? If so, make sure your binding is not occuring on postback, i.e. if you have something like: Page_Load { BindMyGridView(); } make if Page_Load { if (!Page.IsPostBack) BindMyGridView(); }

        1 Reply Last reply
        0
        • K kjosh

          Hi, Iam implementing shoppingcart.In that i placed a Gridview with columns Name,price,picture,checkboxfield(select). User select the items from the gridview and click on ADDCART Button which is outside of GridView. when user click ADDCART button,the rows in the gridview for which checkbox field checked that vales iam storing in a datatable. for this ADDCART button click event i wrote the following code: int c=0; for (int i = 0; i < GridView1.Rows.Count; i++) { GridViewRow row = GridView1.Rows[i]; bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked; if (isChecked) c++; } Response.Write(c.ToString()); //This code only to check. Eventhough i checked 2 checkbox fields,and click on ADDCART The c value is 0. Anything wrong in the above code. Or Give me some idea on How to ADD user selected items to CART. Please help me. Thanks in advance

          N Offline
          N Offline
          NasimKaziS
          wrote on last edited by
          #4

          hey.. the code works completely fine.. pls check the name of the checkbox u have placed and the name u have given in the FinControl Method is same. it works fine.

          where there is a will there is a way

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups