ajax

V

Victor Rodriguez

How can I make a Gridview to page up/down inside of:
<updatepanel>
<ContentTemplate>
<GridView></GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="cmdGoFind" EventName="Click"
/>
<asp:AsyncPostBackTrigger ControlID="cmdRefresh"
EventName="Click" />
</Triggers>
</updatepanel>

Thanks,

Victor
 
W

Walter Wang [MSFT]

Hi Victor,

I'm not sure what do you mean of "page up/down" of the GridView. Do you
mean to scroll the GridView up/down or switch to prev/next page if the
GridView is paged?

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.
 
V

Victor Rodriguez

I need to move from page 1 with 20 records to page 2 with 20 more records
using the paging tools of GridView.

Victor
 
W

Walter Wang [MSFT]

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:pubsConnectionString %>"
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.
 
V

Victor Rodriguez

I'm not using custom paging, I'm using what comes with GridView and whenever
I click to page it does not executes the command.

Victor
 
W

Walter Wang [MSFT]

Hi Victor,

Can you please post your code here? or you can send your complete to me via
email. This should work by default.

If you start from scratch to create a new WebForm to use my code, does it
work? Maybe this is related to your ajax configuration in web.config? Have
you checked that if other simple operations can work (such as putting a
Label and Button in UpdatePanel and changes Label.Text in Button.Click)?


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.
 
W

Walter Wang [MSFT]

Hi Victor,

I'm writing to check the status of this post. Please feel free to let me
know if there's anything else I can help. Thanks.


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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top