asp.net中的GridView控件的部分知识点

时间:2023-12-31 13:04:08
<PagerTemplate>

            <br />
<asp:Label ID="lblPage" runat="server" Text='<%# "第" + (((GridView)Container.NamingContainer).PageIndex + 1) + "页/共" + (((GridView)Container.NamingContainer).PageCount) + "页" %> '></asp:Label>
<asp:LinkButton ID="lbnFirst" runat="Server" Text="首页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>' CommandName="Page" CommandArgument="First" ></asp:LinkButton>
<asp:LinkButton ID="lbnPrev" runat="server" Text="上一页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>' CommandName="Page" CommandArgument="Prev" ></asp:LinkButton>
<asp:LinkButton ID="lbnNext" runat="Server" Text="下一页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != (((GridView)Container.NamingContainer).PageCount - 1) %>' CommandName="Page" CommandArgument="Next" ></asp:LinkButton>
<asp:LinkButton ID="lbnLast" runat="Server" Text="尾页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != (((GridView)Container.NamingContainer).PageCount - 1) %>' CommandName="Page" CommandArgument="Last" ></asp:LinkButton>
到第 <asp:TextBox ID="txtPageNumber" runat="server"></asp:TextBox>
<asp:Button ID="btnPage" Text="Go" runat="server" CommandName="MyPage" />
</PagerTemplate>

GridView---数据绑定控件之数据表格

什么是数据源

  通过数据源控件可以直接绑定数据 2.可以设置“自动套用格式”来改变样式(外观) 3.可以通过数据源控制实现在线编辑、删除、选中 4.通过自动生成列,可以使GridView从数据源中自动提取列信息 5.GridView可以包含多种列类型:BoundField(绑定列)、CheckBoxField(复选框列)、HyperLinkField(超链接列)、、ImageField(图片列)、ButtonField(按钮列)、CommonField(命令列)、TemplateField(模板列) 6.GridView内置了很多命令:edit、delete、update、cancel、select、自定义命令

  其中,TemplateField模板可分为:内容模板、编辑行模板、交替行模板、头模板、尾模板

  今天,给大家共享一个关于网站开发中分页的代码,希望可以用上哦,小伙伴们