private void Bind() { DataTable dtSizegroup = new DataTable(); try { Cls_groupmaster_b clsGroup = new Cls_groupmaster_b(); dtSizegroup = clsGroup.SelectAll(); } catch { } finally { } if (dtSizegroup != null) { if (dtSizegroup.Rows.Count > 0) { lstGroup.DataSource = dtSizegroup; lstGroup.DataTextField = "groupname"; lstGroup.DataValueField = "id"; lstGroup.DataBind(); } else { lstGroup.DataSource = dtSizegroup; lstGroup.DataTextField = "groupname"; lstGroup.DataValueField = "id"; lstGroup.DataBind(); } } else { lstGroup.DataSource = dtSizegroup; lstGroup.DataTextField = "groupname"; lstGroup.DataValueField = "id"; lstGroup.DataBind(); } }
private void Bind() { //List<SelectListItem> list = new List<SelectListItem>(); DataTable dtArticle = new DataTable(); DataTable dtColor = new DataTable(); DataTable dtSize = new DataTable(); DataTable dtEmployee = new DataTable(); //if (dtProduct == null) //{ // System.Web.UI.WebControls.ListItem objListItem = new System.Web.UI.WebControls.ListItem("--Select Product(s)--", "0"); // ddlProduct.Items.Insert(0, objListItem); //} try { Cls_product_b clsProduct = new Cls_product_b(); dtArticle = clsProduct.SelectAll(); Cls_color_b clsColor = new Cls_color_b(); dtColor = clsColor.SelectAll(); //Cls_size_b clsSize = new Cls_size_b(); //dtSize = clsSize.SelectAll(); Cls_groupmaster_b clsSize = new Cls_groupmaster_b(); dtSize = clsSize.SelectAll(); Cls_Employee_b clsEmployee = new Cls_Employee_b(); dtEmployee = clsEmployee.SelectAll(); } catch { } finally { con.Close(); } if (dtArticle != null) { if (dtArticle.Rows.Count > 0) { ddlArticle.DataSource = dtArticle; ddlArticle.DataTextField = "productname"; ddlArticle.DataValueField = "pid"; ddlArticle.DataBind(); System.Web.UI.WebControls.ListItem objListItem = new System.Web.UI.WebControls.ListItem("--Select Article--", "0"); ddlArticle.Items.Insert(0, objListItem); } } if (dtColor != null) { if (dtColor.Rows.Count > 0) { //ddlColor.DataSource = dtColor; //ddlColor.DataTextField = "colorname"; //ddlColor.DataValueField = "cid"; //ddlColor.DataBind(); //System.Web.UI.WebControls.ListItem objListItem = new System.Web.UI.WebControls.ListItem("--Select Color--", "0"); //ddlColor.Items.Insert(0, objListItem); lstColor.DataSource = dtColor; lstColor.DataTextField = "colorname"; lstColor.DataValueField = "cid"; lstColor.DataBind(); //System.Web.UI.WebControls.ListItem objListItem = new System.Web.UI.WebControls.ListItem("--Select Color--", "0"); //lstColor.Items.Insert(0, objListItem); } else { lstColor.DataSource = dtColor; lstColor.DataTextField = "colorname"; lstColor.DataValueField = "cid"; lstColor.DataBind(); } } else { lstColor.DataSource = dtColor; lstColor.DataTextField = "colorname"; lstColor.DataValueField = "cid"; lstColor.DataBind(); } if (dtSize != null) { if (dtSize.Rows.Count > 0) { //ddlSize.DataSource = dtSize; //ddlSize.DataTextField = "sizeName"; //ddlSize.DataValueField = "cid"; //ddlSize.DataBind(); //System.Web.UI.WebControls.ListItem objListItem = new System.Web.UI.WebControls.ListItem("--Select Size--", "0"); //ddlSize.Items.Insert(0, objListItem); lstSize.DataSource = dtSize; lstSize.DataTextField = "groupname"; lstSize.DataValueField = "id"; lstSize.DataBind(); } else { lstSize.DataSource = dtSize; lstSize.DataTextField = "groupname"; lstSize.DataValueField = "id"; lstSize.DataBind(); } } else { lstSize.DataSource = dtSize; lstSize.DataTextField = "groupname"; lstSize.DataValueField = "id"; lstSize.DataBind(); } if (dtEmployee != null) { if (dtEmployee.Rows.Count > 0) { Session["employee"] = dtEmployee; ddlEmployee.DataSource = dtEmployee; ddlEmployee.DataTextField = "employeeName"; ddlEmployee.DataValueField = "id"; ddlEmployee.DataBind(); System.Web.UI.WebControls.ListItem objListItem = new System.Web.UI.WebControls.ListItem("--Select Employee--", "0"); ddlEmployee.Items.Insert(0, objListItem); } } }