不过可以自已写分页控件来支持DataList,详细看
http://www.icad.com.cn/article/list.asp?id=505
http://www.icad.com.cn/article/list.asp?id=505
解决方案 »
- 问一个超级简单的问题,使用了Console.Write("HI")为什么没输出
- 请问,在一个程序中启动另外一个程序,当启动完成(出现主界面)以后,主程序能够知道吗?
- 有人了解Excel VBA宏吗,我用VB代码去执行没问题,但是C#代码却不行
- 在线等,第一次发帖,不信等不来回复,提问!
- 急!怎么把上传文件保存在另一台机子上,高手请进
- 如何关闭已经打开的端口?System.Net.Sockets.SocketException: 通常每个套接字地址 (协议/网络地址/端口) 只允许使用一次
- 在C#如何只得到记录的条数
- 关于winform的
- Oracle 设置了 BindByName 不起作用。
- 为何我用Socket发送的是一窜字符,而接收的却是空值??????????????????????
- 问一个关于dataset合并的问题
- 遇到了一个怪问题,程序中有两个窗体,想在F1里运行F2,但怎么也实例不到 Form f2 = new (找不到F2)怎么回事啊?
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
try
{
string connstr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =" + Server.MapPath("book.asp");
string sql = "select * from guest order by id desc" ;
OleDbConnection conn = new OleDbConnection( connstr ) ;
OleDbDataAdapter da = new OleDbDataAdapter( sql,conn);
DataSet ds = new DataSet();
da.Fill(ds); PagedDataSource objpds = new PagedDataSource();
objpds.DataSource = ds.Tables[0].DefaultView;
objpds.AllowPaging = true;
objpds.PageSize = 8;
int currentpage;
if(Request.QueryString["page"] != null)
currentpage = Convert.ToInt32(Request.QueryString["page"]);
else
currentpage = 1;
objpds.CurrentPageIndex = currentpage-1;
lblCurrentpage.Text = "当前页" + currentpage.ToString();
if( !objpds.IsFirstPage )
this.lnkprev.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(currentpage-1);
if( !objpds.IsLastPage )
this.lnknext.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(currentpage+1); main.DataSource = objpds;
main.DataBind(); }
catch(Exception ex )
{
Response.Write("错误:" + ex.ToString());
}
}
这个例子是repeater的。但是使用datalist。也就是我上面的方法。
http://www.csharphelp.com/archives3/archive544.html?printable=yes
你的main是什么控件
PagedDataSource 我在窗体里面也没找到直接可以用吗?