,當點擊一個按鈕,這裏是代碼此按鈕值不能爲空mscorlib.dll中
{
int i = int.Parse(TextBox1.Text);
int p = int.Parse((string)ViewState["PricePerCube"]); //error on this line
string img = ViewState["Image"].ToString();
string s2 = System.Web.HttpContext.Current.User.Identity.Name;
string s1 = Request.QueryString["TreeInCart"];
SqlConnection a = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
a.Open();
string cartCmd = "insert into FullCart(TreeInCart,QuantityCubed,User,Image,PricePerCube) values('" + s1 + "','" + i + "','" + s2 + "','" + img + "','" + p + "') ";
SqlCommand cmd = new SqlCommand(cartCmd, a);
cmd.ExecuteNonQuery();
a.Close();
當你通過在調試器中執行代碼,你發現了什麼? – HABO
檢查我編輯的問題,這是調出「值不能爲空」的錯誤代碼,並且在設置ViewState [「PricePerCube」]'時調試它時顯示爲零 – billz
? – Imad