由于 我不会用这个控件 所有上网查了 下 找到
如下 代码public partial class _Default : System.Web.UI.Page
{ protected OleDbConnection conn = new OleDbConnection();
protected OleDbCommand cmd = new OleDbCommand();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
initdb();
conn.Open();
cmd.CommandText = "select count(*) from t_product";
AspNetPager1.RecordCount = (int)cmd.ExecuteScalar();
conn.Close();
BindData();
} }
protected void BindData()
{
initdb();
OleDbDataAdapter sda = new OleDbDataAdapter("select * from t_product", conn);
DataSet ds = new DataSet();
//sda.Fill(ds, 10, 10, "temptbl");
sda.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "temptbl");
DataList1.DataSource = ds.Tables["temptbl"];
DataList1.DataBind();
} protected void initdb()
{
conn.ConnectionString = oledbtool.myConnStr + Server.MapPath(oledbtool.mydbName);
cmd.Connection = conn;
} protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
BindData();
}
}
但为何 报这样的错错误 4 “System.EventArgs”不包含“NewPageIndex”的定义,并且找不到可接受类型为“System.EventArgs”的第一个参数的扩展方法“NewPageIndex”(是否缺少 using 指令或程序集引用?)这句 要添加什么引用吗 ??AspNetPager1.CurrentPageIndex = e.NewPageIndex;
我看了类似的 都写这样的 代码 但为什么我会报错
不解
如下 代码public partial class _Default : System.Web.UI.Page
{ protected OleDbConnection conn = new OleDbConnection();
protected OleDbCommand cmd = new OleDbCommand();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
initdb();
conn.Open();
cmd.CommandText = "select count(*) from t_product";
AspNetPager1.RecordCount = (int)cmd.ExecuteScalar();
conn.Close();
BindData();
} }
protected void BindData()
{
initdb();
OleDbDataAdapter sda = new OleDbDataAdapter("select * from t_product", conn);
DataSet ds = new DataSet();
//sda.Fill(ds, 10, 10, "temptbl");
sda.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "temptbl");
DataList1.DataSource = ds.Tables["temptbl"];
DataList1.DataBind();
} protected void initdb()
{
conn.ConnectionString = oledbtool.myConnStr + Server.MapPath(oledbtool.mydbName);
cmd.Connection = conn;
} protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
BindData();
}
}
但为何 报这样的错错误 4 “System.EventArgs”不包含“NewPageIndex”的定义,并且找不到可接受类型为“System.EventArgs”的第一个参数的扩展方法“NewPageIndex”(是否缺少 using 指令或程序集引用?)这句 要添加什么引用吗 ??AspNetPager1.CurrentPageIndex = e.NewPageIndex;
我看了类似的 都写这样的 代码 但为什么我会报错
不解
AspNetPager1 能用Ajax吗
参考:http://www.ej38.com/askshow/ajax-127648.html
{
//AspNetPager1.CurrentPageIndex = e.NewPageIndex;
BindData();
}
asp.net版本的好像没有
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
bind(); // 直接绑定数据即可
}