private void GetAllProductIds() { try { clsProducts objProd = new clsProducts(); DataSet dsProdData = objProd.GetAllProductsData(); if (dsProdData.Tables[0].Rows.Count != 0) { ddlProducts.DataSource = dsProdData.Tables[0]; ddlProducts.DataTextField = "ProductName"; ddlProducts.DataValueField = "ProductId"; ddlProducts.DataBind(); ddlProducts.Items.Insert(0, "--Select One--"); } else { ddlProducts.Items.Insert(0, "--Select One--"); ddlProducts.Items.Insert(1, "No Products"); } } catch (Exception ex) { lblMsg.Text = ex.Message; } }
protected void btnShowAll_Click(object sender, EventArgs e) { try { divProducts.Visible = false; if (btnShowAll.Text == "Show All") { objPro = new clsProducts(); DataSet ds = objPro.GetAllProductsData(); if (ds.Tables[0].Rows.Count != 0) { grdProducts.DataSource = ds.Tables[0]; grdProducts.DataBind(); } else { grdProducts.EmptyDataText = "Record not found."; grdProducts.DataBind(); } btnShowAll.Text = "Close Grid"; divProducts.Visible = true; } else if (btnShowAll.Text == "Close Grid") { btnShowAll.Text = "Show All"; divProducts.Visible = false; } } catch (Exception ex) { lblMsg.Text = ex.Message; } }
void GetProducts() { DataSet ds = objProd.GetAllProductsData(); if (ds.Tables[0].Rows.Count != 0) { DropDownList1.DataSource = ds; DropDownList1.DataTextField = "ProductName"; DropDownList1.DataValueField = "ProductId"; DropDownList1.DataBind(); DropDownList1.Items.Insert(0, "--Select One--"); } }
private void GetAllProdId() { try { objProd = new clsProducts(); DataSet ds = objProd.GetAllProductsData(); ddlProdMaster.DataSource = ds; ddlProdMaster.DataValueField = "ProductId"; ddlProdMaster.DataTextField = "ProductName"; ddlProdMaster.Items.Insert(0, "--Select One--"); } catch (Exception ex) { lblMsg.Text = ex.Message; } }