////////////////分页处理程序;
void Page_Load(Object sender, EventArgs e)
{
if (CheckBox1.Checked)
ItemsGrid.PagerStyle.Mode=PagerMode.NumericPages;
else
ItemsGrid.PagerStyle.Mode=PagerMode.NextPrev;
if (!IsPostBack)
{
start_index = 0;
ItemsGrid.VirtualItemCount=100;
}
BindGrid();
}
/////////////邦定公用函数;
void BindGrid()
{
ItemsGrid.DataSource=CreateDataSource();
ItemsGrid.DataBind();
}
///////////////////////// 数据库的链 接在前面已经发表过的,!
1<asp:datagrid &="" allowcustompaging="true" allowpaging="true" autogeneratecolumns="false" backimageurl="Images\image1.jpg" bordercolor="black" borderwidth="1" cellpadding="3" false;="" id="ItemsGrid" onpageindexchanged="Grid_Change" runat="server" 换页开关;="" 改变属性数据格会不一样有:true="" 背景图象;="" 行间隔;=""> //分页驱动程序ID
2//分页默认样式;
3<pagerstyle backcolor="#00aaaa" nextpagetext="Forward" pagebuttoncount="5" position="Bottom" prevpagetext="Back">
4</pagerstyle>
5<alternatingitemstyle backcolor="yellow">
6</alternatingitemstyle>
7<headerstyle backcolor="#00aaaa">
8</headerstyle>
9<columns>
10<asp:boundcolumn datafield="IntegerValue" headertext="Number"></asp:boundcolumn>
11<asp:boundcolumn datafield="StringValue" headertext="Item"></asp:boundcolumn>
12<asp:boundcolumn datafield="CurrencyValue" dataformatstring="{0:c}" headertext="Price">
13<itemstyle horizontalalign="right">
14</itemstyle>
15</asp:boundcolumn>
16</columns>
17</asp:datagrid>
1<br/>
//选择数字显示分页
1<asp:checkbox autopostback="true" id="CheckBox1" runat="server" text="Show page navigation"></asp:checkbox>