页面没有数据控件,所有数据都在dataset里面,页面输出用for循环,请问能用aspnetpager实现分页不?如果可以,该如何做?
解决方案 »
- 请问在点韦Labe或者Image时,可以让它们像点击Button一样Postback一下吗?
- Button控件验证后PostBackUrl不跳转的问题。
- 求助!!!'ASP 0177 : 80070003'
- 大家帮忙啊js+xml生成三级树的问题啊!
- Membership插入人员问题
- 关于GridView遇到的问题
- 类型“TextBox”的控件“tbMsg”必须放在具有 runat=server 的窗体标记内.
- 邮件发送后老是提示邮件发送失败,望各位指教
- AutoCompleteExtender
- 急问???如何弹出打开文件对话框,选择要用的文件,读出文件数据,然后将文件数据写入access数据库中,请写详细代码!!!
- 时间字段的比较问题!
- 求一个博客模块
/// <summary>
/// 获取记录数
/// </summary>
/// <param name="table"></param>
/// <param name="cond">格式:Where ...</param>
/// <returns></returns>
public int GetRowCount(string table, string cond)
{
string query = string.Format("Select count(*) From {0} {1}", table, cond);
DataSet ds = db.GetDataSet(query);
if (ds != null)
{
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
return Galsun.Common.Utils.StrToInt(ds.Tables[0].Rows[0][0].ToString(), 0);
}
}
return 0; }
/// <summary>
///
/// </summary>
/// <param name="table"></param>
/// <param name="rowpage"></param>
/// <param name="rowcount"></param>
/// <param name="orderFid"></param>
/// <param name="Conditions"></param>
/// <returns></returns>
public DataSet GetinfoList(string table, int rowpage, int rowcount, string orderFid, string Conditions)
{ string query = "Select * From "
+ "(Select *,ROW_NUMBER() OVER(ORDER BY {2}) as RowNum From {4} {3}) as newTable "
+ "Where (RowNum BETWEEN ({0}) AND ({1}))";
query = string.Format(query, (rowpage - 1) * rowcount + 1, rowpage * rowcount, orderFid, Conditions, table); //string query = "Select top {0} * From {1} {2} and id not in(Select top {3} id From {1} {2} Order by {4}) Order by {4}";
//query = string.Format(query, rowcount, table, Conditions, (rowpage - 1) * rowcount + 1, orderFid);
return db.GetDataSet(query); }
//应用都是一样的 protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bindData();
}
}
void bindData()
{ string cond = " Where isCheck=1 and sid=2 "; //初使化一个SQL语句str //绑定数据
AspNetPager1.RecordCount = GetRowCount("gl_NewsSystem", cond);
DataTable dt = GetinfoList("gl_NewsSystem", AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, " OrderID DESC,FBDate DESC,id DESC", cond);
foreach(DataRow item in dt.Rows)
{
.......
}
}
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
bindData();//更新页面数据
}
public void Bind()
{
int Top = 0;
string strWhere = " IsTrue=1 and Type=5 ";
string filedOrder = "Time desc";
BLL.BOOK book = new BLL.BOOK();
DataSet set = new DataSet();
set = book.GetList(Top, strWhere, filedOrder);
int pagesize = AspNetPager1.PageSize;
int currentpage = AspNetPager1.CurrentPageIndex;
imd = book.GetListTo(Top, strWhere, filedOrder, pagesize * (currentpage - 1), pagesize); AspNetPager1.RecordCount = set.Tables[0].Rows.Count;
}