public void ShowCategoryInfo(string strID) { DAL.CMS.CategoryDAL dal = new DAL.CMS.CategoryDAL(); DataSet ds = dal.GetCategoryByID(strID); Model.CMS.CMS_Category model = DataConvert.DataRowToModel <Model.CMS.CMS_Category>(ds.Tables[0].Rows[0]); this.txtName.Text = model.Name; this.hd_content.Value = model.Content; this.txtSummary.Text = model.Summary; this.txtLink.Text = model.Link; this.txtOrder.Text = model.Order.ToString(); this.img0.Src = "../../" + model.Pic; if (strAction == "show") { this.btnReset.Visible = false; this.btnSave.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Session["strSiteCode"].ToString()) && Session["strRoleCode"].ToString() != "ADMIN") { Response.Write("<script language=JavaScript>;parent.location.href='../Login.aspx';</script>"); Response.End(); } if (!IsPostBack) { this.ddlCategory.Items.Clear(); DAL.CMS.CategoryDAL dal = new DAL.CMS.CategoryDAL(); DataSet ds = new DataSet(); if (GlobalSession.strRoleCode == "ADMIN") { ds = dal.GetAllCategory(""); } else { ds = dal.GetAllCategory(" SiteCode ='" + Session["strSiteCode"].ToString() + "' "); } DataTable dt = ds.Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { this.ddlCategory.Items.Add(dt.Rows[i]["Name"].ToString()); } DataRow dr = ds.Tables[0].NewRow(); dr["ID"] = "0"; dr["Name"] = ""; dt.Rows.InsertAt(dr, 0); this.ddlCategory.DataSource = ds.Tables[0].DefaultView; this.ddlCategory.DataTextField = "Name"; this.ddlCategory.DataValueField = "ID"; this.ddlCategory.DataBind(); } }
const string vsKey = "searchCriteria"; //ViewState key /// <summary> /// 页面加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ddlCategory.Items.Clear(); DAL.CMS.CategoryDAL dal = new DAL.CMS.CategoryDAL(); DataSet ds = new DataSet(); if (Session["strRoleCode"].ToString() == "ADMIN") { ds = dal.GetAllCategory(""); } else { ds = dal.GetAllCategory(" SiteCode ='" + Session["strSiteCode"].ToString() + "' "); } DataTable dt = ds.Tables[0]; DataRow dr = ds.Tables[0].NewRow(); dr["ID"] = "0"; dr["Name"] = "--全部--"; dt.Rows.InsertAt(dr, 0); this.ddlCategory.DataSource = ds.Tables[0].DefaultView; this.ddlCategory.DataTextField = "Name"; this.ddlCategory.DataValueField = "ID"; this.ddlCategory.DataBind(); AspNetPager1.CurrentPageIndex = 1; string s = ""; if (Session["strRoleCode"].ToString() != "ADMIN") { s = " a.SiteCode = '" + Session["strSiteCode"].ToString() + "' "; } ViewState[vsKey] = s; LoadData(s); } }