1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SearchNotice.aspx.cs" Inherits="SignetPortal.Views.Mobile.SerchNotice" %> 2 3 <%@ Import Namespace="SignetPortal.Share.UnClass" %> 4 <%@ Import Namespace="SignetPortal.Share.AllHelper" %> 5 6 7 843 449 10 12 13 14 15 20 21 22
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Web.UI; 6 using System.Web.UI.WebControls; 7 using System.Data; 8 9 namespace SignetPortal.Views.Mobile 10 { 11 public partial class SerchNotice : System.Web.UI.Page 12 { 13 ///14 /// 创建分页数据源的对象 15 /// 16 protected PagedDataSource psd = new PagedDataSource(); 17 protected static int PageIndex = 0; 18 19 20 protected void Page_Load(object sender, EventArgs e) 21 { 22 } 23 ///24 /// 通过 url 获取地域编码 25 /// 26 ///27 protected static string GetArea() 28 { 29 System.Web.UI.Page page = System.Web.HttpContext.Current.Handler as System.Web.UI.Page; 30 string area = "1301"; 31 if (page != null) 32 { 33 string queryString = System.Web.HttpContext.Current.Request.QueryString["area"].ToString(); 34 35 //string queryString = System.Web.HttpContext.Current.Request.Url.Query; 36 //queryString.Substring(queryString.Length - 4); 37 38 area = queryString; 39 if (area != "1308" && area != "1311" && area != "1307" && area != "1306" && area != "1305" && area != "1301") 40 { 41 area = "1301"; 42 } 43 44 } 45 return area; 46 } 47 48 protected void Page_PreRender(object sender, EventArgs e) 49 { 50 Session["CityId"] = GetArea(); 51 if (Session["CityId"] == null) 52 { 53 Response.Redirect("Index.aspx", false); 54 return; 55 } 56 if (!Page.IsPostBack) 57 { 58 BindNotice(sender, e); 59 } 60 } 61 private void BindNotice(object sender, EventArgs e) 62 { 63 try 64 { 65 string noticeSection = Request.QueryString["NoticeSection"].ToString(); 66 string cityId = "1301"; 67 if (Session["CityId"] != null) 68 { 69 cityId = Session["CityId"].ToString(); 70 } 71 Share.UnClass.PageExerciser pv = new Share.UnClass.PageExerciser(); 72 DataTable dt = Logic.Bll.News.SearchNotice(pv, noticeSection, cityId); 73 if (dt != null) 74 { 75 psd.AllowPaging = true; 76 psd.PageSize = 5; 77 //获取总页数 78 int pageCount = dt.Rows.Count % 5 == 0 ? dt.Rows.Count / 5 : dt.Rows.Count / 5 + 1; 79 80 if (sender is int && PageIndex > 0 && pageCount > 1) 81 { 82 PageIndex--; 83 84 } 85 else if (sender is string && (PageIndex + 1) < pageCount) 86 { 87 PageIndex++; 88 } 89 90 psd.CurrentPageIndex = PageIndex; 91 92 psd.DataSource = dt.DefaultView; 93 Rpdata.DataSource = psd; 94 Rpdata.DataBind(); 95 96 97 //Rpdata.DataSource = dt; 98 //Rpdata.DataBind(); 99 }100 }101 catch (Exception ex)102 {103 }104 }105 106 protected void lbtnpritPage_Click(object sender, EventArgs e)107 {108 sender = -1;109 }110 111 protected void lbtnNextPage_Click(object sender, EventArgs e)112 {113 sender = "Next";114 this.BindNotice(sender, e);115 }116 }117 }