ajax

Discussion in 'ASP .Net Web Controls' started by Victor Rodriguez, Aug 28, 2007.

  1. 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
    Victor Rodriguez, Aug 28, 2007
    #1
    1. Advertising

  2. 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 (, 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.
    Walter Wang [MSFT], Aug 29, 2007
    #2
    1. Advertising

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

    Victor


    ""Walter Wang [MSFT]"" <> wrote in message
    news:BDilv$...
    > 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 (, 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.
    >
    Victor Rodriguez, Aug 29, 2007
    #3
  4. 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 (, 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.
    Walter Wang [MSFT], Aug 30, 2007
    #4
  5. 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


    ""Walter Wang [MSFT]"" <> wrote in message
    news:...
    > 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 (, 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.
    >
    Victor Rodriguez, Aug 30, 2007
    #5
  6. 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 (, 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.
    Walter Wang [MSFT], Aug 31, 2007
    #6
  7. 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 (, 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.
    Walter Wang [MSFT], Sep 5, 2007
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    20
    Views:
    1,898
    d1srupt3r
    Mar 31, 2008
  2. darrel

    beginner AJAX questions (AJAX.net)

    darrel, Apr 27, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    2,436
    Flinky Wisty Pomm
    Apr 28, 2006
  3. jobs
    Replies:
    0
    Views:
    365
  4. =?Utf-8?B?QnJpYW4gRWR3YXJkcw==?=

    Deploying ASP.NET AJAX-Enabled Web site to host without AJAX insta

    =?Utf-8?B?QnJpYW4gRWR3YXJkcw==?=, Feb 20, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    591
    Patrick
    Feb 21, 2007
  5. minnie
    Replies:
    1
    Views:
    684
    Andrew Thompson
    Dec 13, 2006
Loading...

Share This Page