I am converting the entered values in textbox into decimal values to saev in sql table. In case user does not enter any value i get a Format exception. How do i handle this..
My code is as below
DMLObj.Add("ItemID", Convert.ToInt32(drpitemname.SelectedValue).ToString());
DMLObj.Add("SupplierName", Convert.ToInt32(drpvendor.SelectedValue).ToString());
DMLObj.Add("Quantity", Convert.ToDecimal(txtqty.Text).ToString());//qty.ToString());
DMLObj.Add("Unit", Convert.ToInt32(drpunit.SelectedValue).ToString());
DMLObj.Add("ListPrice", Convert.ToDecimal(txtListPrice.Text).ToString());//listprice.ToString());
DMLObj.Add("DiscountPercentage", Convert.ToDecimal(txtdiscountpercentage.Text).ToString());
DMLObj.Add("Discount", Convert.ToDecimal(txtdiscount.Text).ToString());//Session["DISCOUNT"].ToString());
DMLObj.Add("TaxPercentage", Convert.ToDecimal(txttaxper.Text).ToString());
DMLObj.Add("Tax", Session["TAX"].ToString());//tax.ToString());
DMLObj.Add("NetPrice", Convert.ToDecimal(txtTotal.Text).ToString());// Session["TOTAL"].ToString());