Gridview的 不显示
场景:GridView的 <PagerTemplate>为什么不显示出来解决思路
GridView的 <PagerTemplate>为什么不显示出来
前台代码如下:
<asp:Panel ID="Panel1" runat="server" Width="950px" Height="400px">
<asp:GridView ID="dgv_GWCheck" runat="server" RowHeadersVisible="true"
AutoGenerateColumns="False" BackColor="White" BorderColor="#DEDFDE" PageSize="3"
BorderStyle="None" BorderWidth="1px" CellPadding="4" EmptyDataText="没有数据"
DataSourceID="GWCheckEntity" ForeColor="Black" DataKeyNames="G_ID"
Width="950px" AllowPaging="True" AllowCustomPaging="true">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="G_ID" ReadOnly="True" Visible="false"
SortExpression="G_ID" >
<ItemStyle />
</asp:BoundField>
<asp:BoundField DataField="Statue" HeaderText="状态" ReadOnly="True"
SortExpression="Statue" >
<ItemStyle Width="65px" />
...........
</Columns>
<FooterStyle BackColor="#CCCC99" />
<HeaderStyle BackColor="#CCCC99" Font-Bold="True" ForeColor="White" Font-Size="16px" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle BackColor="#F7F7DE" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FBFBF2" />
<SortedAscendingHeaderStyle BackColor="#848384" />
<SortedDescendingCellStyle BackColor="#EAEAD3" />
<SortedDescendingHeaderStyle BackColor="#575357" />
<RowStyle HorizontalAlign ="Center" Height="5px" />
<HeaderStyle Height="15px" />
<PagerTemplate>当前页:<asp:Label ID="LabelCurrentPage" runat="server" Text="<%# ((GridView)Container.NamingContainer).PageIndex + 1 %>"></asp:Label>
共<asp:Label ID="LabelPageCount" runat="server" Text="<%# ((GridView)Container.NamingContainer).PageCount %>"></asp:Label>页
<asp:LinkButton ID="LinkButtonFirstPage" runat="server" CommandArgument="First" CommandName="Page" OnCommand="PageButtonClick"
Visible="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>">首页</asp:LinkButton>
<asp:LinkButton ID="LinkButtonPreviousPage" runat="server" CommandArgument="Prev" CommandName="Page" OnCommand="PageButtonClick"
Visible="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>">上一页</asp:LinkButton>
<asp:LinkButton ID="LinkButtonNextPage" runat="server" CommandArgument="Next" CommandName="Page" OnCommand="PageButtonClick"
Visible="<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>">下一页</asp:LinkButton>
<asp:LinkButton ID="LinkButtonLastPage" runat="server" CommandArgument="Last" CommandName="Page" OnCommand="PageButtonClick"
Visible="<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>">尾页</asp:LinkButton>
转<asp:TextBox ID="UserDefinePage" runat="server" Width="30px"></asp:TextBox>页 <asp:LinkButton ID="TurnPage" CommandName="go" runat="server">GO</asp:LinkButton></PagerTemplate>
</asp:GridView>
<asp:SqlDataSource ID="GWCheckEntity" runat="server" ConnectionString="<%$ ConnectionStrings:SCZF_OAConnectionString %>" SelectCommand="SELECT G_ID,Statue,G_Title,Dep_Name,U_Name,G_RegisterTime FROM [Table_GongWenRegister],[Table_UserInfo],[Table_Department] WHERE Table_GongWenRegister.U_ID=Table_UserInfo.U_ID AND Table_UserInfo.U_statue='在职'AND Table_UserInfo.Dep_ID=Table_Department.Dep_ID"></asp:SqlDataSource>
</asp:Panel>
数据库中的记录数绝对多余3条。就是显示不出PagerTemplate里面的内容
------解决方案--------------------
数据量不足一页的话是不会出现的
------解决方案--------------------
sorry ! 没看到PageSize = 3
------解决方案--------------------
http://www.cnblogs.com/weiqt/articles/2031683.html
你要是想分页的话,那么使用使用AspNetPager控件实现GridView分页吧。
很强大的控件哈。
GridView的 <PagerTemplate>为什么不显示出来
前台代码如下:
<asp:Panel ID="Panel1" runat="server" Width="950px" Height="400px">
<asp:GridView ID="dgv_GWCheck" runat="server" RowHeadersVisible="true"
AutoGenerateColumns="False" BackColor="White" BorderColor="#DEDFDE" PageSize="3"
BorderStyle="None" BorderWidth="1px" CellPadding="4" EmptyDataText="没有数据"
DataSourceID="GWCheckEntity" ForeColor="Black" DataKeyNames="G_ID"
Width="950px" AllowPaging="True" AllowCustomPaging="true">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="G_ID" ReadOnly="True" Visible="false"
SortExpression="G_ID" >
<ItemStyle />
</asp:BoundField>
<asp:BoundField DataField="Statue" HeaderText="状态" ReadOnly="True"
SortExpression="Statue" >
<ItemStyle Width="65px" />
...........
</Columns>
<FooterStyle BackColor="#CCCC99" />
<HeaderStyle BackColor="#CCCC99" Font-Bold="True" ForeColor="White" Font-Size="16px" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle BackColor="#F7F7DE" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FBFBF2" />
<SortedAscendingHeaderStyle BackColor="#848384" />
<SortedDescendingCellStyle BackColor="#EAEAD3" />
<SortedDescendingHeaderStyle BackColor="#575357" />
<RowStyle HorizontalAlign ="Center" Height="5px" />
<HeaderStyle Height="15px" />
<PagerTemplate>当前页:<asp:Label ID="LabelCurrentPage" runat="server" Text="<%# ((GridView)Container.NamingContainer).PageIndex + 1 %>"></asp:Label>
共<asp:Label ID="LabelPageCount" runat="server" Text="<%# ((GridView)Container.NamingContainer).PageCount %>"></asp:Label>页
<asp:LinkButton ID="LinkButtonFirstPage" runat="server" CommandArgument="First" CommandName="Page" OnCommand="PageButtonClick"
Visible="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>">首页</asp:LinkButton>
<asp:LinkButton ID="LinkButtonPreviousPage" runat="server" CommandArgument="Prev" CommandName="Page" OnCommand="PageButtonClick"
Visible="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>">上一页</asp:LinkButton>
<asp:LinkButton ID="LinkButtonNextPage" runat="server" CommandArgument="Next" CommandName="Page" OnCommand="PageButtonClick"
Visible="<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>">下一页</asp:LinkButton>
<asp:LinkButton ID="LinkButtonLastPage" runat="server" CommandArgument="Last" CommandName="Page" OnCommand="PageButtonClick"
Visible="<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>">尾页</asp:LinkButton>
转<asp:TextBox ID="UserDefinePage" runat="server" Width="30px"></asp:TextBox>页 <asp:LinkButton ID="TurnPage" CommandName="go" runat="server">GO</asp:LinkButton></PagerTemplate>
</asp:GridView>
<asp:SqlDataSource ID="GWCheckEntity" runat="server" ConnectionString="<%$ ConnectionStrings:SCZF_OAConnectionString %>" SelectCommand="SELECT G_ID,Statue,G_Title,Dep_Name,U_Name,G_RegisterTime FROM [Table_GongWenRegister],[Table_UserInfo],[Table_Department] WHERE Table_GongWenRegister.U_ID=Table_UserInfo.U_ID AND Table_UserInfo.U_statue='在职'AND Table_UserInfo.Dep_ID=Table_Department.Dep_ID"></asp:SqlDataSource>
</asp:Panel>
数据库中的记录数绝对多余3条。就是显示不出PagerTemplate里面的内容
------解决方案--------------------
数据量不足一页的话是不会出现的
------解决方案--------------------
sorry ! 没看到PageSize = 3
------解决方案--------------------
http://www.cnblogs.com/weiqt/articles/2031683.html
你要是想分页的话,那么使用使用AspNetPager控件实现GridView分页吧。
很强大的控件哈。