c# - Input string was not in a correct format even i have the right values in it -
i have shopping cart website. when submit "submit order button" giving me error saying input string not in correct format. below, have code declared variables.
public class shoppingcart { public string categoryname; public int categoryid; public int productid; public int customerid; public string productname; public string productimage; public string productprice; public string productdescription; public int productquantity; public string bankdepositimage; public string customername; public string customeremailid; public string customerphoneno; public string customeraddress; public string productlist; public string paymentmethod; public string orderstatus; public string orderno; public int totalproducts; public int totalprice; public int stocktype; public int flag;
in code textboxes.
shoppingcart k = new shoppingcart() { customername = txtcustomername.text, customeremailid = txtcustomeremailid.text, customeraddress = txtcustomeraddress.text, customerphoneno = txtcustomerphoneno.text, totalproducts = convert.toint32(txttotalproducts.text), totalprice = convert.toint32(txttotalprice.text), productlist = productids, paymentmethod = rblpaymentmethod.selecteditem.text };
i receiving error in shopping k = new shopping cart line of code. confused on problem given inputting right value on each text box. please , thank you
try using int32.parse
totalprice = int32.parse(txttotalproducts.text)
and steve suggests, make sure input devoid of decimals.
Comments
Post a Comment