用AspNetPager和ViewState分别实现asp.net分页
以下介绍两种分页,用AspNetPager和ViewState
一.AspNetPager的用法
1. 复制AspNetPager.dll到bin目录,在工具箱->选择项->浏览,添加bin下的引用。
2. 从工具箱拖个AspNetPager,改如下属性:
PageSize--每页显示的记录数
CustomInfoHTML--自定义显示文本,一般为“第%CurrentPageIndex%页 共%PageCount%页”
ShowCustomInfoSection--显示当前页和总页数信息,值为Never,Right,Left
AlwaysShow--总是显示分页控件
PageIndexBoxType--指定页索引框的显示类型,值为文本框,下拉列表框
ShowPageIndexBox--指定页索引框的显示方式,值为Always,Never,Auto
TextAfterPageIndexBox--页索引框后的文本内容,一般为“页”
TextBeforePageIndexBox--页索引框前的文本内容,一般为“转到”
显示如下
3. 在AspNetPager的PageChanged事件中写如下代码:
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
Databind();
}
private void Databind()
{
PagedDataSource pds = new PagedDataSource();
pds.DataSource = List<T>;
pds.AllowPaging = true;
pds.PageSize = AspNetPager1.PageSize; //AspNetPager1是ID
AspNetPager1.RecordCount = pds.DataSourceCount;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
GridView1.DataSource = pds; //绑定到GridView
GridView1.DataBind();
}
二. ViewState
1.四个按钮触发以下
相关文档:
有很久一段时间我的BLOG上没有出现AJAX相关讯息了,主要当然是因为绝大部分的重心都放到了Silverlight身上(可预期的未来应该也会是如此)。
但由于工作上的需要,最近还是回头看了一下即将推出的ASP.NET Ajax Library...,顺便找了一下网络上的讯息,看这个态势我猜想应该不少ASP.NET开发人员忽略掉了这个其实已经bet ......
Web.config文件是一个标准的XML文档,所有的配置信息都位于<configuration>标记内。<system.web>标记内则包含了核心ASP.NET配置设置。用户可以在Visual Studio.NET中打开Web.config来查看和编辑它的内容,这个文件中包含了大量的注释信息,用户可以参照学习。下面介绍几个常用的标记。
1. <appSettings> ......
(一).选择会话状态存储方式
在Webconfig文件配置:
<sessionState mode="???" stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=y ......
1.
ClientScript.RegisterStartupScript(this.GetType(), "js1", "alert('删除成功');window.location='QuerySortList.aspx';", true);
2.
this.cmdSave.Attributes.Add("onclick", "return f_StringCheck()"); ......
这里我只摘取了原文的Code以供潜心研究.using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data.SqlClient;
using System.Web.Security;
using System.Data;
public ......