protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bind();
}
} protected void bind()
{
String Zl = Request.QueryString["zlname"].ToString();
string sqlstr = "select * from y_newnr inner join (select * from y_newlm )as a on a.lmid=y_newnr.lmid where zlname='" + Zl + "'";
OleDbConnection conn = new OleDbConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
PagedDataSource ps = new PagedDataSource();
OleDbDataAdapter da = new OleDbDataAdapter(sqlstr, conn);
DataSet ds = new DataSet();
da.Fill(ds, "y_newnr");
ps.DataSource = ds.Tables["y_newnr"].DefaultView;
AspNetPager1.RecordCount = ps.Count;
ps.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
ps.AllowPaging = true;
ps.PageSize = AspNetPager1.PageSize;
GridView1.DataSource = ps;
GridView1.DataBind();
}
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
bind();
}
这个能查出对应的数据出来,可是Aspnetpager就是不显示,绑定这里被我弄的乱七八糟的了在本论坛搜索了一个源码,但是我不会写AccessHelper,各位哥哥们能帮帮小弟写个绑定或者AccessHelper.cs吧,谢谢!
protected void bind()
{
string sql = "select * from news";
string con = AccessHelper.conn;
PagedDataSource ps = new PagedDataSource();
ps.DataSource = AccessHelper.ExecuteDataSet(con, sql).Tables[0].DefaultView;
AspNetPager1.RecordCount = ps.Count;
ps.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
ps.AllowPaging = true;
ps.PageSize = AspNetPager1.PageSize;
DataList1.DataSource = ps;
DataList1.DataBind();
}access分页aspnetpager
{
if (!IsPostBack)
{
bind();
}
} protected void bind()
{
String Zl = Request.QueryString["zlname"].ToString();
string sqlstr = "select * from y_newnr inner join (select * from y_newlm )as a on a.lmid=y_newnr.lmid where zlname='" + Zl + "'";
OleDbConnection conn = new OleDbConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
PagedDataSource ps = new PagedDataSource();
OleDbDataAdapter da = new OleDbDataAdapter(sqlstr, conn);
DataSet ds = new DataSet();
da.Fill(ds, "y_newnr");
ps.DataSource = ds.Tables["y_newnr"].DefaultView;
AspNetPager1.RecordCount = ps.Count;
ps.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
ps.AllowPaging = true;
ps.PageSize = AspNetPager1.PageSize;
GridView1.DataSource = ps;
GridView1.DataBind();
}
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
bind();
}
这个能查出对应的数据出来,可是Aspnetpager就是不显示,绑定这里被我弄的乱七八糟的了在本论坛搜索了一个源码,但是我不会写AccessHelper,各位哥哥们能帮帮小弟写个绑定或者AccessHelper.cs吧,谢谢!
protected void bind()
{
string sql = "select * from news";
string con = AccessHelper.conn;
PagedDataSource ps = new PagedDataSource();
ps.DataSource = AccessHelper.ExecuteDataSet(con, sql).Tables[0].DefaultView;
AspNetPager1.RecordCount = ps.Count;
ps.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
ps.AllowPaging = true;
ps.PageSize = AspNetPager1.PageSize;
DataList1.DataSource = ps;
DataList1.DataBind();
}access分页aspnetpager
解决方案 »
- 请教sql查询怎么忽略重复行
- 如何用正则表达式控件来判断,输入的内容为非负数字?
- 如何得到 DATAVIEW 筛选后的表
- 怎么把一个图片存放到SQL SERVER2000
- 把一个Excel文件用鼠标拖入IE窗口打开,如何捕捉这一事件呢?
- 怎样让vs2005与Dreamvaver同步?
- 关于DataGrid格式化字符串的问题
- Asp.Net + Flash 上传的组件,文件上传后返回值问题,急!
- 我用ASP.NET OLEDB连接 SYBASE ,可是把数据绑定到datagrid后怎么中文都是乱码?
- ★★★真得要高手才好解决的问题???大家都来试试吧★★★
- 怎么让gridview列局部刷新
- 求教vs2005中jquery调用aspx页面,相关事件无法触发
我总共8条数据,我设置成PageSize="4",另外4条就被它吃了,没了,aspnetpager控件也没显示
下面这段代码也是别人写的,应该是OK的,能把其中的AccessHelper用上面的代码替换了吗,新手不会用类啊
DataTable result = new DataTable();
PagedDataSource pds = new PagedDataSource();
result = BLL.GetResult(); //获取数据
AspNetPager1.RecordCount = result.Rows.Count;
pds.AllowPaging = true;
pds.PageSize = AspNetPager1.PageSize;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
pds.DataSource = result.DefaultView;
gvResult.DataSource = pds;
gvResult.DataBind();
protected void bindData()
{
String Zl = Request.QueryString["zlname"].ToString();
string sqlstr = "select * from y_newnr inner join (select * from y_newlm )as a on a.lmid=y_newnr.lmid where zlname='" + Zl + "'";
this.AccessDataSource1.DataFile="E:/dgwz/data/db1.mdb";
this.AccessDataSource1.SelectCommand=sqlstr;
PagedDataSource pds = new PagedDataSource();
pds.AllowPaging = true;
pds.PageSize = AspNetPager1.PageSize;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
DataView dv = (DataView)AccessDataSource1.Select(DataSourceSelectArguments.Empty);
pds.DataSource = dv;
GridView1.DataSource = pds;
GridView1.DataBind();
} protected void AspNetPager1_PageChanged(object src, EventArgs e)
{
bindData();
} protected void AccessDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
AspNetPager1.RecordCount = e.AffectedRows;
}