private void BindEmployee() { DataTable dt = new DataTable(); try { Cls_Employee_b obj = new Cls_Employee_b(); dt = obj.SelectAll(); if (dt != null) { if (dt.Rows.Count > 0) { ddlemp.DataSource = dt; ddlemp.DataTextField = "employeeName"; ddlemp.DataValueField = "id"; ddlemp.DataBind(); ListItem objListItem = new ListItem("--Select Employee--", "0"); ddlemp.Items.Insert(0, objListItem); } } } catch (Exception ex) { } finally { con.Close(); } }
private void Bind() { //List<SelectListItem> list = new List<SelectListItem>(); DataTable dtEmployee = new DataTable(); DataTable dtCity = new DataTable(); try { Cls_Employee_b clsEmployee = new Cls_Employee_b(); dtEmployee = clsEmployee.SelectAll(); cls_CityMaster_b clscity = new cls_CityMaster_b(); dtCity = clscity.SelectAll(); } catch { } finally { con.Close(); } if (dtEmployee != null) { if (dtEmployee.Rows.Count > 0) { Session["employee"] = dtEmployee; lstemployee.DataSource = dtEmployee; lstemployee.DataTextField = "employeeName"; lstemployee.DataValueField = "id"; lstemployee.DataBind(); //System.Web.UI.WebControls.ListItem objListItem = new System.Web.UI.WebControls.ListItem("--Select Employee--", "0"); //lstemployee.Items.Insert(0, objListItem); } } lstemployee.SelectedIndex = 0; if (dtCity != null) { if (dtCity.Rows.Count > 0) { Session["city"] = dtCity; lstCity.DataSource = dtCity; lstCity.DataTextField = "cityname"; lstCity.DataValueField = "id"; lstCity.DataBind(); //System.Web.UI.WebControls.ListItem objListItem = new System.Web.UI.WebControls.ListItem("--Select City--", "0"); //lstCity.Items.Insert(0, objListItem); } } //lstCity.SelectedIndex = 0; }
private void BindEmployee() { try { Cls_Employee_b clsEmployee = new Cls_Employee_b(); dtEmployee = clsEmployee.SelectAll(); if (dtEmployee != null) { if (dtEmployee.Rows.Count > 0) { lstCustomer.DataSource = dtEmployee; lstCustomer.DataTextField = "employeename"; lstCustomer.DataValueField = "id"; lstCustomer.DataBind(); System.Web.UI.WebControls.ListItem objListItem = new System.Web.UI.WebControls.ListItem("--Select Employee--", "0"); lstCustomer.Items.Insert(0, objListItem); } else { lstCustomer.DataSource = dtEmployee; lstCustomer.DataTextField = "employeename"; lstCustomer.DataValueField = "id"; lstCustomer.DataBind(); System.Web.UI.WebControls.ListItem objListItem = new System.Web.UI.WebControls.ListItem("--Select Employee--", "0"); lstCustomer.Items.Insert(0, objListItem); } } else { lstCustomer.DataSource = dtEmployee; lstCustomer.DataTextField = "employeename"; lstCustomer.DataValueField = "id"; lstCustomer.DataBind(); System.Web.UI.WebControls.ListItem objListItem = new System.Web.UI.WebControls.ListItem("--Select Employee--", "0"); lstCustomer.Items.Insert(0, objListItem); } } catch { } finally { con.Close(); } }
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); } } }