Thanks David for your input.
Hi Victor,
As David described, if you're using custom paging of GridView, then you
need to handle the PageIndexChanging event. However, if you're binding to a
DataSource control that supports paging by default (such as SqlDataSource),
then you don't need to handle it and it's already working.
To switch prev/next page without full postback, all you have to do is to
make those buttons a trigger of the UpdatePanel:
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server"
AllowPaging="True" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="au_lname"
HeaderText="au_lname" SortExpression="au_lname" />
<asp:BoundField DataField="au_fname"
HeaderText="au_fname" SortExpression="au_fname" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings

ubsConnectionString %>"
SelectCommand="SELECT [au_lname], [au_fname] FROM
[authors]"></asp:SqlDataSource>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1"
EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="Button2"
EventName="Click" />
</Triggers>
</asp:UpdatePanel>
protected void Button1_Click(object sender, EventArgs e)
{
if (GridView1.PageIndex > 0)
{
GridView1.PageIndex--;
}
}
protected void Button2_Click(object sender, EventArgs e)
{
if (GridView1.PageIndex < GridView1.PageCount - 1)
{
GridView1.PageIndex++;
}
}
I hope I haven't misunderstood your requirement here. Please feel free to
let me know if I did.
Regards,
Walter Wang (
[email protected], remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.