protected void btnPlaceOrder_Click(object sender, EventArgs e) { Transaction ts = new Transaction(); try { ts.CustName = tbCustomerName.Text; ts.CustPhone = int.Parse(tbCustomerPhone.Text); ts.Email = tbCustomerEmail.Text; ts.Address = tbCustomerAddress.Text; ts.NoOfProducts = int.Parse(tbTotalProducts.Text); ts.TotalCost = int.Parse(tbTotalPrice.Text); ts.TransactionId = ts.AddNewTransaction(); } catch { } for (int i = 0; i < dlCart.Items.Count; i++) { try { DataListItem lst = dlCart.Items[i]; HiddenField hd = (HiddenField)lst.FindControl("hfProductID"); Label lblName = (Label)lst.FindControl("lblProductName"); TextBox tbNo = (TextBox)lst.FindControl("tbProductQuantity"); ts.ProductID = int.Parse(hd.Value); ts.ProductName = lblName.Text; ts.NoOfItems = int.Parse(tbNo.Text); ts.SaveTransactionDetails(); } catch { } } int transID = ts.TransactionId; OrderPlacedSuccessFully(transID); }