关于第一个问题:
设置属性: AllowCustomPaging=False AllowPaging=true
而且要求定义事件PageIndexChanged的处理函数,假如语句:
this.DataGrid1.CurrentPageIndex=e.NewPageIndex;
this.DataGrid1.DataBind();
设置属性: AllowCustomPaging=False AllowPaging=true
而且要求定义事件PageIndexChanged的处理函数,假如语句:
this.DataGrid1.CurrentPageIndex=e.NewPageIndex;
this.DataGrid1.DataBind();
解决方案 »
- 怎么修改SiteMapPath 的title
- SQL求百分比
- 请教各位高手,SharePoint2007中SSO如何配制?(顶者有分,解决后立马结贴)
- 一道面试题求解
- 编译器错误信息: CS0117: “string”并不包含“DataSource”的定义,啥意思
- 如何给TextBox控件在失去焦点的时候执行后台函数?
- 急救....button.Click问题
- 看看我的xml文件跟xsl文件是不是不一致
- 网站被挂马!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 如何实现DATAGRID中数据的汇总统计?请进行帮我,我会举个例子说明的!谢谢
- Win2000配置了服务器后Aspx虚拟目录就不能运行了,为什么?
- 页面刷新与赋值的问题,有一点点难度
<%@ Import NameSpace="System.Data" %>
<%@ Import NameSpace="System.Data.oleDB" %><script runat="server">
sub Page_Load(obj as object,e as eventargs)
'set up connection
dim myConnection as oleDBConnection = new oleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\inetpub\wwwroot\bank\banking.mdb") 'open connection
dim myCommand as oleDbDataAdapter = new oleDbDataAdapter _
("select * from Users",myConnection) 'fill dataset
dim ds as Dataset = new dataset()
myCommand.Fill(ds,"Users") 'select data view and bind to server control
DataGrid1.DataSource = ds.Tables("Users").DefaultView
DataBind()
end sub sub DataGrid1_Edit(obj as object,e as _
DataGridCommandEventArgs)
DataGrid1.EditItemIndex = e.Item.ItemIndex
DataGrid1.DataBind()
end sub sub DataGrid1_Cancel(obj as object,e as _
DataGridCommandEventArgs)
DataGrid1.EditItemIndex = -1
DataGrid1.DataBind()
end sub sub DataGrid1_Update(obj as object,e as _
DataGridCommandEventArgs)
'do update
DataGrid1.DataBind()
end sub sub DataGrid1_PageIndexChanged(obj as object,e as _
DataGridPageChangedEventArgs)
DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.DataBind()
end sub
</script><html><body>
<form runat="server">
<asp:DataGrid id="DataGrid1" runat="server"
BorderColor="black" GridLines="Vertical"
Cellpadding="4" Cellspacing="0" width="450"
Font-Name="Arial" Font-Size="8pt"
ShowFooter="True" AutoGenerateColumns="false"
HeaderStyle-BackColor="#cccc99"
FooterStyle-BackColor="#cccc99"
ItemStyle-BackColor="#ffffff"
AlternatingItemStyle-BackColor="#cccccc"
OnEditCommand="DataGrid1_Edit"
OnCancelCommand="DataGrid1_Cancel"
OnUpdateCommand="DataGrid1_Update"
AllowPaging="True"
PageSize=1 PagerStyle-Mode=NumericPages
PagerStyle-PageButtonCount = 15
OnPageIndexChanged="DataGrid1_PageIndexChanged" > <Columns> <asp:TemplateColumn HeaderText="Name">
<ItemTemplate>
<asp:Label id="Name" runat="server"
Text='<%# Container.DataItem("FirstName") & _
" " & Container.DataItem("LastName") %>' />
</ItemTemplate>
</asp:TemplateColumn> <asp:BoundColumn HeaderText="Address"
DataField="Address" /> <asp:BoundColumn HeaderText="City" DataField="City" /> <asp:BoundColumn HeaderText="State" DataField="State" /> <asp:BoundColumn HeaderText="ZIP" DataField="ZIP" /> <asp:EditCommandColumn EditText="Edit"
CancelText="Cancel" UpdateText="Update"
ItemStyle-Wrap="false" HeaderText="Edit" /> </Columns>
</asp:DataGrid>
</form>
</body></html>
我试过,11,12页能够正常显示。另外你固定整个DATAGRID的宽度,让它自己调整每项的宽度,整体看来变化不大,也使得每页的显示协调。
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="GetData"%><html>
<link rel=stylesheet href='../global/index.css'>
<style><!--.item{width:60;height:20}--></style><!------------------------------------------------------------------------------------------------><script language="C#" runat="server"> DataSet my7thDeDS; void Page_Load(Object sender,EventArgs e)
{ Get7thDeData myGetData = new Get7thDeData(); my7thDeDS = myGetData.GetProductMan("ProductMan"); ProductManDataGrid.CurrentPageIndex = 0;
BindDataGrid(); } void ChangePage(Object objSender, DataGridPageChangedEventArgs objArgs )
{ // update the current page number from the parameter values
ProductManDataGrid.CurrentPageIndex = objArgs.NewPageIndex; // recreate the data set and bind it to the DataGrid control
BindDataGrid();
} void BindDataGrid()
{
ProductManDataGrid.DataSource = my7thDeDS.Tables["ProductMan"].DefaultView;
ProductManDataGrid.DataBind();
}</script><!------------------------------------------------------------------------------------------------><body bgcolor="#F5F5F5" leftmargin="0" topmargin="0" oncontextmenu='return false' onselectstart='return false' onkeydown=return(!(event.keyCode==78&&event.ctrlKey))>
<table width="100%" border="0" cellspacing="0" bgcolor="0080c0">
<tr>
<td> </td>
</tr>
<tr>
<td height="6" colspan="2" bgcolor="#FFFF00"></td>
</tr>
</table>
<p align="center">
<form runat="server">
<asp:DataGrid Width="80%" id='ProductManDataGrid' CellPadding="2" CellSpacing="0" runat='Server' AutoGenerateColumns="False" ShowFooter="True" AllowPaging="True" OnPageIndexChanged="ChangePage" GridLines="Vertical" AllowCustomPaging=False PageSize="15" BorderColor="#999999" BorderWidth="1" EnableViewState="false" >
<AlternatingItemStyle BackColor="#E3E3E3" />
<HeaderStyle BackColor="#0066CC" ForeColor="#FFFFFF" Font-Name="宋体" Font-Size="9pt" Font-Bold="true" />
<ItemStyle Font-Name="宋体" Font-Size="9pt" Width="40" />
<FooterStyle BackColor="#0066CC" ForeColor="#FFFFFF" />
<PagerStyle Mode="NumericPages" HorizontalAlign="Right" />
<SelectedItemStyle BackColor="Yellow" />
<Columns>
<asp:BoundColumn HeaderText="项目名称" DataField="pItemName" ItemStyle-Wrap="false" />
<asp:BoundColumn HeaderText="开始日期" DataField="pBeginDate" DataFormatString="{0:D}" />
<asp:BoundColumn HeaderText="结束日期" DataField="pEndDate" DataFormatString="{0:D}" />
<asp:BoundColumn HeaderText="获奖级别" DataField="pAwardLevel" />
</Columns>
</asp:DataGrid>
</form>
</p>
</body>
<html>
主题:我想问一下DataList能分页么??如果能如何实现
中的回复