コード例 #1
0
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        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='../Index.aspx';</script>");
                Response.End();
            }
            if (!IsPostBack)
            {
                #region 初始化界面
                this.ddlAlbumType.Items.Clear();
                AlbumTypeDAL dal = new AlbumTypeDAL();
                DataSet      ds  = new DataSet();
                if (GlobalSession.strRoleCode == "ADMIN")
                {
                    ds = dal.GetAlbumTypeByIsDel("");
                }
                else
                {
                    ds = dal.GetAlbumTypeByIsDel(" 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.ddlAlbumType.DataSource     = ds.Tables[0].DefaultView;
                this.ddlAlbumType.DataTextField  = "Name";
                this.ddlAlbumType.DataValueField = "ID";
                this.ddlAlbumType.DataBind();

                if (null != Common.Common.NoHtml(Request.QueryString["action"]))
                {
                    strAction = Common.Common.NoHtml(Request.QueryString["action"]);
                }
                if (null != Common.Common.NoHtml(Request.QueryString["id"]))
                {
                    strID = Common.Common.NoHtml(Request.QueryString["id"]);
                }
                #endregion
            }
        }
コード例 #2
0
        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();
                AlbumTypeDAL dal = new AlbumTypeDAL();
                DataSet      ds  = new DataSet();
                if (Session["strRoleCode"].ToString() == "ADMIN")
                {
                    ds = dal.GetAlbumTypeByIsDel("");
                }
                else
                {
                    ds = dal.GetAlbumTypeByIsDel(" 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 = " b.SiteCode = '" + Session["strSiteCode"].ToString() + "' ";
                }
                ViewState[vsKey] = s;
                LoadData(s);
            }
        }