Saturday, March 24, 2012

Paging Sample

Hi there. Here there is an absolute newbie to Ajax. I'm looking for an Ajax sample for gridview/datagrid paging. Where can i find a -closed- sample?

Thanks in advance.

There is no difference to implement asp:GridView paging?between?asp.net?2.0?and?Ajax.Here?are?some?sample?codes?for?your?reference.
<div>
<asp:UpdatePanel ID="pnlGuestbook" runat="server">
<ContentTemplate>
<asp:GridView ID="gvGuestBook" Width="250" CssClass="NotifyTable" DataSourceID="SqlDataSource2" PageSize="2" AllowPaging="True" runat="server" AutoGenerateColumns="False" DataKeyNames="Message_ID">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table>
<tr>
<td><br />
<%#Eval("Subject")%>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ButtonType="Button" >
<ItemStyle VerticalAlign="Top" />
</asp:CommandField>
</Columns>
<PagerSettings Mode="NumericFirstLast" FirstPageText="First" NextPageText="Next" LastPageText="Last" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ProductConnectionString %>"
SelectCommand="SELECT [Message_ID], [From], [Subject], [DateSent] FROM [Message]">
</asp:SqlDataSource>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="gvGuestBook" EventName="PageIndexChanged"></asp:AsyncPostBackTrigger>
</Triggers>
</asp:UpdatePanel>
</div>
Wish this can help you.
Thank you. It was so simple. Just drag and drop two controls (ScriptManager and UpdatePanel) and put GridView in UpdatePanel. Love it. =)

No comments:

Post a Comment