Пример #1
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)
            {
                ddlRaceList.Items.Clear();
                RC_RaceDAL dal = new RC_RaceDAL();
                DataSet    ds  = new DataSet();
                if (Session["strRoleCode"].ToString() == "ADMIN")
                {
                    ds = dal.GetRCRList("");
                }
                else
                {
                    ds = dal.GetRCRList("   SiteCode ='" + Session["strSiteCode"].ToString() + "' ");
                }
                DataTable dt = ds.Tables[0];

                DataRow dr = ds.Tables[0].NewRow();
                dr["ID"]     = 0;
                dr["Rtitle"] = "--全部--";
                dt.Rows.InsertAt(dr, 0);

                this.ddlRaceList.DataSource     = ds.Tables[0].DefaultView;
                this.ddlRaceList.DataTextField  = "Rtitle";
                this.ddlRaceList.DataValueField = "ID";
                this.ddlRaceList.DataBind();

                AspNetPager1.CurrentPageIndex = 1;
                string s = "";
                if (Session["strRoleCode"].ToString() != "ADMIN")
                {
                    s = " and b.SiteCode = '" + Session["strSiteCode"].ToString() + "' ";
                }
                ViewState[vsKey] = s;
                LoadData(s);
            }
        }
Пример #2
0
        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="strWhere">条件</param>
        void LoadData(string strWhere)
        {
            txtName.Text = "";
            RC_RaceDAL dal = new RC_RaceDAL();
            DataSet    ds  = dal.GetRCRList(strWhere);
            DataView   dv  = ds.Tables[0].DefaultView;

            AspNetPager1.RecordCount = dv.Count;

            PagedDataSource pds = new PagedDataSource();

            pds.DataSource       = dv;
            pds.AllowPaging      = true;
            pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
            pds.PageSize         = AspNetPager1.PageSize;
            Repeater1.DataSource = pds;
            Repeater1.DataBind();
        }