Oracle 分页实例 带分页控件用法
1、分页
PageSize 页数大小
CurrentPageIndex 显示第几页
NumericButtonCount 显示多少页
2、后台 绑定 GridView
public void bangding()
{
RADIO_BUTTON_BIZ biza = new RADIO_BUTTON_BIZ();
DROP_DOWN_BOX_BIZ bizdrop = new DROP_DOWN_BOX_BIZ();
RECEIPT_INFORMATION_BIZ bizrec = new RECEIPT_INFORMATION_BIZ();
AirMGRManager airbiz = new AirMGRManager();
int userids = Convert.ToInt32(Session["userid"]);
if (airbiz.Get_CountTongGuo_Biz(userids) == 0)
wua.Style.Value = "display:black";
else
wua.Style.Value = "display:none";
this.AspNetPager1.RecordCount = airbiz.Get_CountTongGuo_Biz(userids);//总页数
int pagesiz = this.AspNetPager1.PageSize;//页数大小
int pagenum = this.AspNetPager1.CurrentPageIndex;//第几页
strpage = "" + pagenum;
GridView1.DataSource = airbiz.Get_PageAirTongGuo_Biz(userids, pagesiz, pagenum);
GridView1.DataKeyNames = new string[] { "RID" };//主键
GridView1.DataBind();
for (int i = 0; i < GridView1.Rows.Count; i++)
{
int xinxiid = Convert.ToInt32(GridView1.DataKeys[i].Value);
string aa = bizrec.Select_Count_Biz(xinxiid, userids, 0, 9);
string bb = bizrec.Select_Count_Biz(xinxiid, userids, 1, 9);
((Label)GridView1.Rows[i].Cells[9].Controls[0].FindControl("Label4")).Text = "未读:" + aa;
((Label)GridView1.Rows[i].Cells[9].Controls[0].FindControl("Label5")).Text = "已读:" + bb;
GridView1.Rows[i].Cells[2].Text =
bizdrop.Select_Name_Biz(Convert.ToInt32(GridView1.Rows[i].Cells[2].Text));
GridView1.Rows[i].Cells[7].Text =
bizdrop.Select_Name_Biz(Convert.ToInt32(GridView1.Rows[i].Cells[7].Text));
GridView1.Rows[i].Cells[10].Text =
Convert.ToDateTime(GridView1.Rows[i].Cells[10].Text).ToString("yyyy-MM-dd");
}
}
3、方法
public List Select_PageByDangerGuoQi(int userid, int pagesize, int
pagenum)//查询危险品运输信息 过期信息 带分页
{
List list = new List();
string sql = string.Format("select * from (select a.*,ROWNUM RN from (select * from
MIS.TRAIN_DANGEROUS_GOODS where USERID={0} and STATUS!=2 and STOP_TIME={2}*{1}-{1}+1", userid,
pagesize, pagenum);
DataTable dt = DBHelper.GetDataSet(sql);
foreach (DataRow row in dt.Rows)
{
WebpsnDangerousGoods dang = new WebpsnDangerousGoods();
dang.TDGTYPE = Convert.ToInt32(row["TDGTYPE"]);
dang.SPACE = row["SPACE"].ToString();
dang.START_STATION = row["START_STATION"].ToString();
dang.END_STATION = row["END_STATION"].ToString();
dang.GOODSNAME = row["GOODSNAME"].ToString();
dang.GOODSNUMBER = Convert.ToInt32(row["GOODSNUMBER"]);
dang.RELEASE_TIME = Convert.ToDateTime(row["RELEASE_TIME"]);
dang.STOP_TIME = Convert.ToDateTime(row["STOP_TIME"]);
dang.VIEWS = Convert.ToInt32(row["VIEWS"]);
dang.TDGID = Convert.ToInt32(row["TDGID"]);
dang.CONTACTG = row["CONTACTG"].ToString();
dang.CONTACTG_PH = row["CONTACTG_PH"].ToString();
list.Add(dang);
}
return list;
}
4、public string Get_Count(int userid, int status)//查询分页个数
{
string sql = string.Format("select count(*) from mis.Train_Dangerous_Goods where USERID={0}
and STATUS={1}", userid, status);
DataTable dt = DBHelper.GetDataSet(sql);
return dt.Rows[0][0].ToString();
}