protected void Page_Load(object sender, EventArgs e) { if (Session["user"] == null) { Server.Transfer("login.aspx"); } if (!IsPostBack) { DdlCategory.DataBind(); } }
private void BindCategory() { using (SqlConnection con = new SqlConnection(ConnectString)) { con.Open(); SqlCommand cmd = new SqlCommand("Select * from Tbl_Category", con); SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows.Count != 0) { DdlCategory.DataSource = dt; DdlCategory.DataTextField = "CategoryName"; DdlCategory.DataValueField = "CategoryId"; DdlCategory.DataBind(); DdlCategory.Items.Insert(0, new ListItem("-Select-", "0")); } } }
protected void Page_Load(object sender, EventArgs e) { ItemBusinessLogic ilogic = new ItemBusinessLogic(); List <Category> catList = EFBroker_Category.GetCategoryList(); Category temp = new Category(); temp.CategoryID = 0; temp.CategoryName = "Other"; catList.Add(temp); DdlCategory.DataSource = catList; DdlCategory.DataTextField = "CategoryName"; DdlCategory.DataValueField = "CategoryID"; List <string> UOMList = EFBroker_Item.GetDistinctUOMList(); UOMList.Add("Other"); DdlUOM.DataSource = UOMList; if (Session["itemlist"] == null) { iList = new List <Item>(); LblSubtitle.Visible = false; } else { iList = (List <Item>)Session["itemlist"]; if (iList.Count != 0) { LblSubtitle.Visible = true; } } // data population gvItemAdded.DataSource = iList; gvItemAdded.DataBind(); if (!IsPostBack) { DdlUOM.DataBind(); DdlCategory.DataBind(); } ControlToUpdate(TxtCategory, DdlCategory); ControlToUpdate(TxtUOM, DdlUOM); }
protected void Page_Load(object sender, EventArgs e) { string SrtConnString = WebConfigurationManager.ConnectionStrings["SageConnnetionString"].ConnectionString; SqlConnection db = new SqlConnection(SrtConnString); try { db.Open(); if (!Page.IsPostBack) { List <string> _Userinfo = new List <string>(); _Userinfo = (List <string>)Session["Userinfo"]; if (Session["Userinfo"] != null) { string Username = _Userinfo[3].ToString(); HdnUser.Value = Username; } else { Response.Redirect(ResolveClientUrl("~/")); } StringBuilder sb = new StringBuilder(); sb.AppendLine(" SELECT PA_ID "); sb.AppendLine(" ,pf.PF_Name "); sb.AppendLine(" ,pf.PF_ID "); sb.AppendLine(" ,PA_Name "); sb.AppendLine(" ,case when PA_Status = 1 then 'Active' else 'In-Active' end as [Status] "); sb.AppendLine(" ,UpdatedDate "); sb.AppendLine(" FROM HR_PointActivity as pa "); sb.AppendLine(" LEFT JOIN HR_PointFamily as pf on pf.PF_ID = pa.PF_ID "); sb.AppendLine(" WHERE 1=1 "); SqlCommand sql = new SqlCommand(sb.ToString(), db); DataTable table = new DataTable(); table.Load(sql.ExecuteReader()); if (table.Rows.Count > 0) { RptPointActivity.DataSource = table; } RptPointActivity.DataBind(); sb = new StringBuilder(); sb.AppendLine(" SELECT PF_ID, "); sb.AppendLine(" PF_Name "); sb.AppendLine(" FROM HR_PointFamily as pf "); sb.AppendLine(" WHERE 1=1 "); sb.AppendLine(" and pf.PF_Status = 1 "); sql = new SqlCommand(sb.ToString(), db); table = new DataTable(); table.Load(sql.ExecuteReader()); if (table.Rows.Count > 0) { DdlCategory.DataSource = table; } DdlCategory.DataBind(); DdlCategory.Items.Insert(0, new ListItem("==== Select ====", "")); } } catch (Exception ex) { Response.Write(ex.Message + "<br/>"); Response.Write(ex.StackTrace + "<br/>"); } finally { db.Close(); } }