DAL层
public DataSet GetPage(int pageindex, int cid)
{
return Common.GetPage("Photo", "ID", 25, pageindex, 0, 1, "Passed=1 AND CID=" + cid);
}Common公共类
public static DataSet GetPage(string tablename, string fldname, int pagesize, int pageindex, int iscount, int ordertype, string strwhere)
{
DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.ConnectionString, CommandType.StoredProcedure, "GetPage", new SqlParameter[]{
new SqlParameter("@tblName",tablename),
new SqlParameter("@fldName",fldname),
new SqlParameter("@PageSize",pagesize),
new SqlParameter("@PageIndex",pageindex),
new SqlParameter("@IsCount",iscount),
new SqlParameter("@OrderType",ordertype),
new SqlParameter("@strWhere",strwhere)
});
return ds;
}UI层
BLL.Photo_BLL photo_bll = new BLL.Photo_BLL();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (!string.IsNullOrEmpty(Request.QueryString["CID"]))
{
int cid = Convert.ToInt32(Request.QueryString["CID"]);
lb_Allpage.Text = Count().ToString();
if (!string.IsNullOrEmpty(Request.QueryString["Page"]))
{
int curpage = Convert.ToInt32(Request.QueryString["Page"]);
lb_CurrentPage.Text = curpage.ToString();
photo_bll.ShowNumber(curpage, Count(), Num, "/Photo/listnews.aspx?CID=" + cid + "&Page=");
Bind(curpage, Count(),cid);
}
else
{
lb_CurrentPage.Text = "1";
photo_bll.ShowNumber(1, Count(), Num, "/Photo/listnews.aspx?CID=" + cid + "&Page=");
Bind( 1, Count(),cid);
}
}
}
}
public int Count()
{
int cid = Convert.ToInt32(Request.QueryString["CID"]);
return photo_bll.GetCount(cid);
}
public void Bind(int pageindex,int countpage,int cid)
{
Re_Bind.DataSource = photo_bll.GetPage(pageindex, cid);
Re_Bind.DataBind();
if (pageindex <= 1)
{
Hy_pre.Enabled = false;
Hy_first.Enabled = false;
Hy_next.NavigateUrl = "/Photo/listnews.aspx?CID=" + cid + "&Page=" + (pageindex + 1).ToString();
Hy_end.NavigateUrl = "/Photo/listnews.aspx?CID=" + cid + "&Page=" + countpage.ToString();
}
else
{
Hy_first.NavigateUrl = "/Photo/listnews.aspx?CID=" + cid + "&Page=1";
Hy_pre.NavigateUrl = "/Photo/listnews.aspx?CID=" + cid + "&Page=" + (pageindex - 1).ToString();
}
if (pageindex > countpage - 1)
{
Hy_first.NavigateUrl = "/Photo/listnews.aspx?CID=" + cid + "&Page=1";
Hy_pre.NavigateUrl = "/Photo/listnews.aspx?CID=" + cid + "&Page=" + (pageindex - 1).ToString();
Hy_next.Enabled = false;
Hy_end.Enabled = false;
}
else
{
Hy_next.NavigateUrl = "/Photo/listnews.aspx?CID=" + cid + "&Page=" + (pageindex + 1).ToString();
Hy_end.NavigateUrl = "/Photo/listnews.aspx?CID=" + cid + "&Page=" + countpage.ToString();
}
}经过昨天各位大侠的指点,学到了点东西
希望各位大侠在指点下有什么不对的地方,该改进的地方
解决方案 »
- .net 批量截取字符串
- 用正则取数据
- DropDownList问题!
- 请问如何在加载网页的时候,自动加载树的第一项根结点?
- 当按下ctrl+c时,从datagrid 复制数据到excel(是Winform窗体),请高人指点~~!顶者有分
- 有关触摸屏的问题
- 如何根据点击显示位置导航(痛苦中ing)
- .net可以实现社会化标签功能吗,就是"tag技术"
- 这是我写的一个翻页函数,我在本机调试什么都是好的,但上传到服务器,他就报这个错,在关键字 'WITH' 附近有语法错误。'ROW_NUMBER' 不是可
- ashx 怎样获取GET方式发来的Json数据
- 高手的快进来~~~~急,急,急
- 用DetailView绑定数据,编辑和新增问题
BLL层
DAL.Photo_DAL photo_dal;
public Photo_BLL()
{
photo_dal = new DAL.Photo_DAL();
}
public DataSet GetPage(int pageindex,int cid)
{
return photo_dal.GetPage(pageindex, cid);
}
希望各位大侠指点迷津!
为何要是静态的?而且还是public?