c# datalist控件 实现分页
小弟的代码如下.usingSystem;usingSystem.Data;usingSystem.Data.OleDb;usingSystem.Configuration...
小弟的代码如下.
using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OleDbConnection coon;
OleDbDataAdapter myda;
coon = new OleDbConnection("provider=Microsoft.JET.OLEDB.4.0;" +
"Data Source=" + Server.MapPath("App_Data/student.mdb"));
myda = new OleDbDataAdapter("select * from sinfo", coon);
DataSet ds = new DataSet();
myda.Fill[ds, "sinfo"];
DataTable dt = new DataTable();
dt = ds.Tables["sinfo"];
PagedDataSource pds = new PagedDataSource();
pds.DataSource = ds.Tables[0].DefaultView;
pds.AllowPaging = true;
pds.PageSize = 3;
int a;
if (Request.QueryString["page"] != null)
{
a = Convert.ToInt32(Request.QueryString["page"]);
}
else
{
a = 1;
}
pds.CurrentPageIndex = a - 1;
this.Label1.Text = "当前第" + a.ToString() + "页";
if (!pds.IsFirstPage) {
this.HyperLink1.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(a - 1);
}
if (!pds.IsLastPage)
{
this.HyperLink1.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(a + 1);
}
this.DataList1.DataSource = pds;
this.DataList1.DataBind();
}
}
他总是跳错说:
错误 1 只有 assignment、call、increment、decrement 和 new 对象表达式可用作语句.
请求各位大仙帮忙解释下这个跳错是什么意思.我的这段代码该如何解决这个问题.
myda.Fill[ds, "sinfo"];
问题出现在这句话. 展开
using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OleDbConnection coon;
OleDbDataAdapter myda;
coon = new OleDbConnection("provider=Microsoft.JET.OLEDB.4.0;" +
"Data Source=" + Server.MapPath("App_Data/student.mdb"));
myda = new OleDbDataAdapter("select * from sinfo", coon);
DataSet ds = new DataSet();
myda.Fill[ds, "sinfo"];
DataTable dt = new DataTable();
dt = ds.Tables["sinfo"];
PagedDataSource pds = new PagedDataSource();
pds.DataSource = ds.Tables[0].DefaultView;
pds.AllowPaging = true;
pds.PageSize = 3;
int a;
if (Request.QueryString["page"] != null)
{
a = Convert.ToInt32(Request.QueryString["page"]);
}
else
{
a = 1;
}
pds.CurrentPageIndex = a - 1;
this.Label1.Text = "当前第" + a.ToString() + "页";
if (!pds.IsFirstPage) {
this.HyperLink1.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(a - 1);
}
if (!pds.IsLastPage)
{
this.HyperLink1.NavigateUrl = Request.CurrentExecutionFilePath + "?page=" + Convert.ToString(a + 1);
}
this.DataList1.DataSource = pds;
this.DataList1.DataBind();
}
}
他总是跳错说:
错误 1 只有 assignment、call、increment、decrement 和 new 对象表达式可用作语句.
请求各位大仙帮忙解释下这个跳错是什么意思.我的这段代码该如何解决这个问题.
myda.Fill[ds, "sinfo"];
问题出现在这句话. 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |