////////////////分页处理程序
void Page_Load(Object sender EventArgs e)
{
if (CheckBoxChecked)
ItemsGridPagerStyleMode=PagerModeNumericPages;
else
ItemsGridPagerStyleMode=PagerModeNextPrev;
if (!IsPostBack)
{
start_index = ;
ItemsGridVirtualItemCount=;
}
BindGrid();
}
/////////////邦定公用函数
void BindGrid()
{
ItemsGridDataSource=CreateDataSource();
ItemsGridDataBind();
}
///////////////////////// 数据库的链 接在前面已经发表过的!
<asp:DataGrid id=ItemsGrid runat=server
BorderColor=black
BorderWidth=
CellPadding= //行间隔
AllowPaging=true //换页开关
AllowCustomPaging=true //
BackImageUrl=Images\imagejpg //背景图象
AutoGenerateColumns=false //改变属性数据格会不一样有true & false
OnPageIndexChanged=Grid_Change> //分页驱动程序ID
//分页默认样式
<PagerStyle NextPageText=Forward
PrevPageText=Back
Position=Bottom
PageButtonCount=
BackColor=#aaaa>
</PagerStyle>
<AlternatingItemStyle BackColor=yellow>
</AlternatingItemStyle>
<HeaderStyle BackColor=#aaaa>
</HeaderStyle>
<Columns>
<asp:BoundColumn HeaderText=Number
DataField=IntegerValue/>
<asp:BoundColumn
HeaderText=Item
DataField=StringValue/>
<asp:BoundColumn
HeaderText=Price
DataField=CurrencyValue
DataFormatString={:c}>
<ItemStyle HorizontalAlign=right>
</ItemStyle>
</asp:BoundColumn>
</Columns>
</asp:DataGrid>
<br>
//选择数字显示分页
<asp:CheckBox id=CheckBox
Text = Show page navigation
AutoPostBack=true
runat=server/>