Paging in Gridview using PagerTemplate

Posted on July 7, 2008. Filed under: Asp.net |

<asp:GridView ID=”gv” Runat=”Server” DataSourceID=”SqlDataSource1″ AutoGenerateColumns=”false”
BorderColor=”#000080″
BorderWidth=”2px”
HorizontalAlign=”Center”
Width=”90%” AllowPaging=true BackColor=Gray  PagerSettings-Position=TopAndBottom  >
<Columns>
<asp:BoundField HeaderText=”localityID” DataField=”localityid”  />
<asp:BoundField HeaderText=”localityName” DataField=”localityname” />

</Columns>

<PagerTemplate>
<asp:LinkButton CommandName=”Page” CommandArgument=”First”
ID=”LinkButton1″ runat=”server” Style=”color: white”>
« First</asp:LinkButton>
<asp:LinkButton CommandName=”Page” CommandArgument=”Prev”
ID=”LinkButton2″ runat=”server” Style=”color: white”>
< Prev</asp:LinkButton>
[Records <%= gv.PageIndex * gv.PageSize%>-<%= gv.PageIndex * gv.PageSize + gv.PageSize - 1%>]
<asp:LinkButton CommandName=”Page” CommandArgument=”Next”
ID=”LinkButton3″ runat=”server” Style=”color: white”>
Next ></asp:LinkButton>
<asp:LinkButton CommandName=”Page” CommandArgument=”Last”
ID=”LinkButton4″ runat=”server” Style=”color: white”>
Last »</asp:LinkButton>
</PagerTemplate>
</asp:GridView>
<asp:SqlDataSource ID=”SqlDataSource1″ runat=”server” SelectCommand=”SELECT * FROM locality”
ConnectionString=”<%$ ConnectionStrings:rubruConnectionString %>” />

Make a Comment

Make A Comment: ( 1 so far )

blockquote and a tags work here.

One Response to “Paging in Gridview using PagerTemplate”

RSS Feed for Dream Asp.net Comments RSS Feed

Thanks for the article

noman
July 21, 2008

Where's The Comment Form?

    About

    Hi,I am Suresh Sharma(MCP) from Gorakhpur , UP, India.I have work on .net technology from 2 years. Key skills-Asp.net 2.0,3.5, Sql 2005,2000. Ajax.net 1.1,C#.net

    RSS

    Subscribe Via RSS

    • Subscribe with Bloglines
    • Add your feed to Newsburst from CNET News.com
    • Subscribe in Google Reader
    • Add to My Yahoo!
    • Subscribe in NewsGator Online
    • The latest comments to all posts in RSS
    • Subscribe in Rojo

    Meta

Liked it here?
Why not try sites on the blogroll...