Input string not in correct format Query string datalist shopping Cart

Adam0808

New Member
I am trying to make an shopping cart web application in asp.net C# and Mysql using Devart LinqConnect(Linq-to-Mysql). I have Categories in a hierarchy when a select an category is displays the corresponding products in the ShowProducts.aspx page. I have added a datalist which Fetches the data from the query String Value.i have assigned to the each category Such as on Category Shirts under mens i have given the Id to the Hyperlinks like \[code\]<li><a href="http://stackoverflow.com/questions/15465113/ShowProducts.aspx?id=8">Mens</a><span class="rarrow">▶</span> <ul class="sub2"> <li><a href="http://stackoverflow.com/questions/15465113/ShowProducts.aspx?id=9">Shirts</a></li>\[/code\]When its is passed on to other page the ShowProducts.aspx As S\[code\]howProducts.aspX?id=9\[/code\], It Displays the products list in the Datalist. As It is Shopping Cart Application I hava a Add To Cart Button when I click the Button Instead Of Adding in the Session Cart Object It is given me an error: \[quote\] Input string was not in a correct format\[/quote\]This is My code in Datalist Item command. \[code\] protected void DataListProducts_ItemCommand(object source, DataListCommandEventArgs e) { if (e.CommandName == "AddToCart") { int RowClicked = Convert.ToInt32(e.CommandArgument); int ProductID = Convert.ToInt32(DataListProducts.DataKeyField[RowClicked]); List<int> ProductsInCart = (List<int>)Session["Cart"]; if (ProductsInCart == null) { ProductsInCart = new List<int>(); } ProductsInCart.Add(ProductID); Session["Cart"] = ProductsInCart; } }\[/code\]please Anybody has an answer to this...
 
Back
Top