Adding Items To Cart
-
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
-
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
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
-
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
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(); }
-
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
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