I searched in this forum, but it didnt help my solve my problem. Please help me.
This is my code
int intOrderNo = (int) Session["sOrderNo"];
DetailsViewRow row0 = DetailsView1.Rows[0];
string strProductId = row0.Cells[1].Text;
DetailsViewRow row6 = DetailsView1.Rows[6];
string strUnitPrice = row6.Cells[1].Text;
float floUnitPrice = float.(strUnitPrice);
string strQty = DropDownList1.Items[DropDownList1.SelectedIndex].ToString();
int intQty = int.Parse(strQty);
string strSQL = "INSERT INTO ItemTable(bOrderNo, bProductId, bQty, bUnitPrice)"
+ "VALUES (@OrderNo, @ProductId, @Qty, @UnitPrice)";
cmd = new OleDbCommand(strSQL, mDB);
cmd.Parameters.AddWithValue("@OrderNo", intOrderNo);
cmd.Parameters.AddWithValue("@ProductId", strProductId);
cmd.Parameters.AddWithValue("@Qty", intQty);
cmd.Parameters.AddWithValue( "@UnitPrice" , floUnitPrice );
mDB.Open();
cmd.ExecuteNonQuery();
mDB.Close();
Response.Redirect("ShoppingCart.aspx");
But i got an error saying that Input String was not in a correct format. Below is the stack trace
[FormatException: Input string was not in a correct format.]
System.Number.ParseSingle(String value, NumberStyles options, NumberFormatInfo numfmt) +9415395
System.Single.Parse(String s) +23
ProductDetails.BuyBtn_Click(Object sender, EventArgs e) in c:\Users\Administrator\Documents\Visual Studio 2010\WebSites\WebSite4\ProductDetails.aspx.cs:39
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563