datalist嵌套 内层datalist 如何使用AspNetPager分页控件

changlr01 2009-08-15 10:08:11
我用的是AspNetPager分页控件来做的,
我写的这个代码,控件页数都正常就是点击每页都是显示的相同的内容
如何解决呢

如果有其他好办法请朋友贴上来~~大家交流一下
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using Wuqi.Webdiyer;
public partial class News_NewsClass : System.Web.UI.Page
{
CommonClass CC = new CommonClass();
DAL.News News = new DAL.News();
int typeid = 0;
DataList dl = new DataList();

protected void Page_Load(object sender, EventArgs e)
{
typeid = Convert.ToInt32(Request.QueryString["typeid"]);

if (!IsPostBack)
{


DataList1.DataSource = News.GetNewsClassName(typeid);
DataList1.DataBind();




}

}

protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{

dl = (DataList)e.Item.FindControl("DataList2");
HyperLink Hy = (HyperLink)e.Item.FindControl("Class1");



AspNetPager1.RecordCount = News.GetNewsClassCount(typeid);//获取文章总数
ClassBindData(typeid,dl);


}



protected void ClassBindData(int typeid, DataList dl)//单个栏目文章列表绑定
{
SqlDataAdapter ada = News.GetAdaNewsClassList(typeid);//获取指定栏目列表的SqlDataAdapter

DataSet set = new DataSet();
ada.Fill(set, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "[0931SEO_NEWS]");
dl.DataSource = set.Tables["[0931SEO_NEWS]"];
dl.DataBind();
ada.Dispose();
set.Dispose();
}

protected void BindData(DataList dl)
{
SqlConnection sql = CC.GetConnection();
string str1 = "select News_ID as id,News_Title as title,News_Intime as intime,News_inname,News_tuijian,News_from,News_liulanliang as liulanliang,type,News_typeid as typeid from view_news where News_mode=2 order by News_id DESC";

SqlDataAdapter ada = new SqlDataAdapter(str1, sql);
sql.Open();
DataSet set = new DataSet();
ada.Fill(set, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "[0931SEO_NEWS]");


dl.DataSource = set.Tables["[0931SEO_NEWS]"];
dl.DataBind();
sql.Close();
}

protected void AspNetPager1_PageChanging1(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;

BindData(dl);

}

}


我写的这个代码,控件页数都正常就是点击每页都是显示的相同的内容
如何解决呢
...全文
92 点赞 收藏 1
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
.NET技术社区
创建于2007-09-28

5.8w+

社区成员

.NET技术交流专区
申请成为版主
帖子事件
创建了帖子
2009-08-15 10:08
社区公告
暂无公告