protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { txtprofit.Text = "0"; txtcostprice.Text = "0"; txtsellingprice.Text = "0"; GridviewProducts.EnableSortingAndPagingCallbacks = false; Handler.Load("Select ProductName, Quantity, CostPrice, SellingPrice from tblProducts", GridviewProducts); //Handler.FillDropdowunList("Select ProductName from tblProducts", dropdowncategory, "ProductName"); Handler.FillDropdowunList("Select CategoryName from tblCategory", dropdowncategory, "CategoryName"); if (User.Identity.IsAuthenticated) { LinkLogout.CausesValidation = false; Lbluser.Text = User.Identity.Name; // ... } } }
protected void Page_Load(object sender, EventArgs e) { Handler.FillDropdowunList("Select * from tblCustomer", drpcustomer, "CustomerName"); if (GridView1.Rows.Count > 0) { checkoutdiv.Visible = true; } else { checkoutdiv.Visible = false; txtsubtotal.Text = "#0"; txtsubtotal1.Text = txtsubtotal.Text.Replace("#", ""); txtvat.Text = ""; txttotalpayment.Text = ""; } if (!IsPostBack) { if (Session["datatable"] != null) { DataTable dt = (DataTable)Session["datatable"]; GridView1.DataSource = dt; GridView1.DataBind(); } if (Session["subtotal"] != null) { txtsubtotal.Text = (string)Session["subtotal"]; txtsubtotal1.Text = txtsubtotal.Text.Replace("#", ""); txtvat.Text = ""; txttotalpayment.Text = ""; } string query = "select * from tblProducts"; string valuefield = "ProductName"; string CS = ConfigurationManager.ConnectionStrings["Connect"].ConnectionString; SqlDataAdapter da = new SqlDataAdapter(); using (SqlConnection con = new SqlConnection(CS)) { da = new SqlDataAdapter(query, con); DataSet ds = new DataSet(); da.Fill(ds); if (da != null) { dropdownproducts.DataSource = ds; dropdownproducts.DataValueField = valuefield; dropdownproducts.DataBind(); } } dropdownproducts.Items.Insert(0, new ListItem("---Select an option---", "")); // Handler.FillDropdowunList(query, dropdownproducts, valuefield); if (User.Identity.IsAuthenticated) { LinkLogout.CausesValidation = false; Lbluser.Text = User.Identity.Name; // ... } } if (GridView1.Rows.Count > 0) { checkoutdiv.Visible = true; } else { checkoutdiv.Visible = false; txtsubtotal.Text = "#0"; txtsubtotal1.Text = txtsubtotal.Text.Replace("#", ""); txtvat.Text = ""; txttotalpayment.Text = ""; } }