一个GridView的PagerTemplate

 

2007年03月29日 星期四 17:31

<PagerTemplate>
<div style="text-align: right;">
      <asp:LinkButton ID="cmdFirstPage" runat="server" CommandName="Page" CommandArgument="First"
       Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=0 %>">首页</asp:LinkButton>
      <asp:LinkButton ID="cmdPreview" runat="server" CommandArgument="Prev" CommandName="Page"
       Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=0 %>">前页</asp:LinkButton>
      第<asp:Label ID="lblcurPage" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageIndex+1      %>'></asp:Label>页/共<asp:Label
       ID="lblPageCount" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageCount %>'></asp:Label>页
      <asp:LinkButton ID="cmdNext" runat="server" CommandName="Page" CommandArgument="Next"
       Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=((GridView)Container.Parent.Parent).PageCount-1 %>">后页</asp:LinkButton>
      <asp:LinkButton ID="cmdLastPage" runat="server" CommandArgument="Last" CommandName="Page"
       Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=((GridView)Container.Parent.Parent).PageCount-1 %>">尾页</asp:LinkButton>
      转<asp:TextBox ID="txtGoPage" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageIndex+1 %>'
       Width="32px" OnTextChanged="txtGoPage_TextChanged" CssClass="inputmini"></asp:TextBox>页</div>
</PagerTemplate>

需要两个方法配合:

txtGoPage_TextChanged
gridresult_PageIndexChanging

 

 

 

protected void txtGoPage_TextChanged(object sender, EventArgs e)
        {
       GridView1.PageIndex =Convert.ToInt32(((TextBox)sender).Text) - 1;
          
            GetData();
        }

你可能感兴趣的:(template)