asp.net 分页问题
为甚么AllowPaging="True"PageIndex="3"这都设了还是不实现分页呢?还是只显示一页。一下是部分代码。。。<asp:AccessDataSourc...
为甚么AllowPaging="True" PageIndex="3" 这都设了还是不实现分页呢?还是只显示一页。
一下是部分代码。。。
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/class.mdb"
SelectCommand="SELECT * FROM [学生通信录] ORDER BY [生日]"></asp:AccessDataSource>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" CellPadding="4" DataKeyNames="学号"
DataSourceID="AccessDataSource1" ForeColor="#333333" GridLines="None"
PageIndex="3">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" /> 展开
一下是部分代码。。。
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/class.mdb"
SelectCommand="SELECT * FROM [学生通信录] ORDER BY [生日]"></asp:AccessDataSource>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" CellPadding="4" DataKeyNames="学号"
DataSourceID="AccessDataSource1" ForeColor="#333333" GridLines="None"
PageIndex="3">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" /> 展开
2个回答
展开全部
其实你不如在后台用数据源对象来实现这一部分的功能 如果用数据源控件的话不但会影响前台排版 另外性能也不见得高
string connString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("App_Data\\bochuang.mdb");
OleDbConnection conn = new OleDbConnection(connString);
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT [mesID],[mesName],[mesContent] FROM [message] order by mesDate desc", conn);
DataSet dt = new DataSet();
conn.Open();
adapter.Fill(dt, "index");
PagedDataSource pageDataSource = new PagedDataSource();
pageDataSource.DataSource = dt.Tables["index"].DefaultView;
pageDataSource.AllowPaging = true;
pageDataSource.PageSize = 5;
pageDataSource.CurrentPageIndex = 1;
this.DataList3.DataSource = pageDataSource;
this.DataList3.DataKeyField = "mesID";
this.DataList3.DataBind();
这是我以前写的Access数据库前台列表分页代码,你可以参考一下
string connString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("App_Data\\bochuang.mdb");
OleDbConnection conn = new OleDbConnection(connString);
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT [mesID],[mesName],[mesContent] FROM [message] order by mesDate desc", conn);
DataSet dt = new DataSet();
conn.Open();
adapter.Fill(dt, "index");
PagedDataSource pageDataSource = new PagedDataSource();
pageDataSource.DataSource = dt.Tables["index"].DefaultView;
pageDataSource.AllowPaging = true;
pageDataSource.PageSize = 5;
pageDataSource.CurrentPageIndex = 1;
this.DataList3.DataSource = pageDataSource;
this.DataList3.DataKeyField = "mesID";
this.DataList3.DataBind();
这是我以前写的Access数据库前台列表分页代码,你可以参考一下
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询