//绑定列表数据 protected void BindRpt() { int totalRecord = 0; //总记录条数 int pageIndex = Request["pageindex"] == null ? 1 : Convert.ToInt32(Request["pageindex"]); //当前页码 int pageSize = 3; //每页条数 string parms = ""; //传递给下一页的条件 string sql = GetSql(out parms); //传递给SQL的查询条件 FenYe fy = new FenYe(); DataTable list = fy.GetList("View_LvLines", "*", "id desc", pageIndex, pageSize, sql, out totalRecord); NetPage pa = new NetPage(pageIndex, pageSize, totalRecord, "loadlineData.aspx", parms, 10); //pagetext = pa.CreatePageHtml();//生成分页html if (list != null) { this.rptList.DataSource = list; this.rptList.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { var code = Request["AreaCode"]; ViewState.Add("AreaCode", code); var keywords = ""; if (!IsPostBack) { var results = new List <LvULinesViewModel>(); var sql = new StringBuilder(); sql.Append(" and IsDel=0 "); sql.Append(string.Format(" and Enddate >='{0}' ", DateTime.Now)); if (!string.IsNullOrEmpty(code)) { var area = DbHelperSQL.Query(string.Format("select * from area where Code='{0}'", code)); if (area != null && area.Tables[0] != null && area.Tables[0].Rows.Count > 0) { var areaName = area.Tables[0].Rows[0]["Name"].ToString(); if (!string.IsNullOrEmpty(areaName)) { areaName = areaName.Replace("市", "").Replace("区", ""); sql.Append(string.Format(" and Splace like '%{0}' ", areaName)); } } } if (!string.IsNullOrEmpty(keywords)) { sql.Append(string.Format(" and Splace like '%{0}%' or TTl like '%{0}%' ", keywords)); } var totalRecord = 0; FenYe fy = new FenYe(); DataTable listdb = fy.GetList("LvULines", "id,Kindof,TTl,Dayscount,Sdate,Enddate,Splace,MainPoint,ProNumCode,adultTicketCount,adultTicketPrice,adultSellPrice,adultzkPrice,puppyTicketCount,puppyTicketPrice,puppySellPrice,puppyzkCount,PuppyLine,Spic,IsTuijian,Isdel,Provider,Providerid,LineMaster,LineMasterTel,LineMasterMoble,Leader,LeaderMobil,JIheTime,JiHePlace,Bianhao", "id desc", 1, 1000, sql.ToString(), out totalRecord); if (listdb == null) { return; } for (int i = 0; i < listdb.Rows.Count; i++) { var model = listdb.Rows[i]; var result = new LvULinesViewModel(); result.id = (int)model["id"]; result.Kindof = (string)model["Kindof"]; result.TTl = (string)model["TTl"]; result.Dayscount = (Byte?)model["Dayscount"]; result.Sdate = (DateTime?)model["Sdate"]; result.Enddate = (DateTime?)model["Enddate"]; result.Splace = (string)model["Splace"]; result.MainPoint = (string)model["MainPoint"]; result.ProNumCode = (string)model["ProNumCode"]; result.adultTicketCount = (int?)model["adultTicketCount"]; result.adultTicketPrice = (int?)model["adultTicketPrice"]; result.adultSellPrice = (int?)model["adultTicketPrice"]; result.adultzkPrice = (int?)model["adultzkPrice"]; result.puppyTicketCount = (int?)model["puppyTicketCount"]; result.puppyTicketPrice = (int?)model["puppyTicketPrice"]; result.puppySellPrice = (int?)model["puppySellPrice"]; result.puppyzkCount = (int?)model["puppyzkCount"]; result.PuppyLine = (string)model["PuppyLine"]; result.Spic = (string)model["Spic"]; result.IsTuijian = model["IsTuijian"] == null ? 0 : (int.Parse(model["IsTuijian"].ToString())); result.Isdel = model["Isdel"] == null ? 0 : (int.Parse(model["Isdel"].ToString())); result.Provider = (string)model["Provider"]; result.Providerid = (int?)model["Providerid"]; result.LineMaster = (string)model["LineMaster"]; result.LineMasterTel = (string)model["LineMasterTel"]; result.LineMasterMoble = (string)model["LineMasterMoble"]; result.Leader = (string)model["Leader"]; result.LeaderMobil = (string)model["LeaderMobil"]; result.JIheTime = (string)model["JIheTime"]; result.JiHePlace = (string)model["JiHePlace"]; result.Bianhao = (string)model["Bianhao"]; var propic = GetViewList(string.Format(" ProNumCode = '{0}'", result.ProNumCode)); if (propic.Tables[0] != null && propic.Tables[0].Rows.Count > 0) { var picstr = propic.Tables[0].Rows[0]["Spicc"]; if (picstr != null && !string.IsNullOrEmpty(picstr.ToString())) { result.LinePic = picstr.ToString(); } } results.Add(result); ViewState["List"] = results; ViewState["IsFirst"] = true; } } else { IsFirst.Value = "2"; ViewState["List"] = new List <LvULinesViewModel>(); ViewState["IsFirst"] = false; } }