How do you save a dynamic datagrid to viewstate?

Discussion in 'ASP .Net Datagrid Control' started by Burak Gunay, Jun 8, 2006.

  1. Burak Gunay

    Burak Gunay Guest

    Hello,

    I have a datagrid on my aspx page without any column definitions.

    <asp:datagrid id="dtgValues" style="Z-INDEX: 101; LEFT: 2px; POSITION:
    relative" Runat="server" PageSize="10" AutoGenerateColumns="False">

    I create the columns and the data dynamically in the code behind
    depending on which table the user selected.

    When I postback the page, I load the grid again.

    If you just use regular paging, and bind the whole dataset to the
    datagrid, then paging works.

    But when i try to use custom paging i run into problems.

    on postback page_load, I load the data again by calling FillGrid()
    function
    , but then when the PageIndexChanged event gets executed,

    Private Sub dtgValues_PageIndexChanged( source , e )
    ' Set the CurrentPageIndex before binding the grid
    dtgValues.CurrentPageIndex = e.NewPageIndex
    FillGrid()
    End Sub

    I end up with two datagrids next to each other.

    Is there a way around this?

    How can I save the datagrid in viewstate and load it again on the
    postback?

    Thanks,

    Burak
     
    Burak Gunay, Jun 8, 2006
    #1
    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. Doris Cox
    Replies:
    0
    Views:
    550
    Doris Cox
    Dec 2, 2003
  2. Dennis
    Replies:
    0
    Views:
    696
    Dennis
    Dec 2, 2003
  3. John Sparrow
    Replies:
    0
    Views:
    394
    John Sparrow
    Jul 1, 2003
  4. =?Utf-8?B?U3Vl?=

    datagrid dynamic web controls viewstate problem

    =?Utf-8?B?U3Vl?=, Dec 2, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    2,059
    =?Utf-8?B?U3Vl?=
    Dec 2, 2005
  5. James
    Replies:
    0
    Views:
    421
    James
    Jul 28, 2006
Loading...

Share This Page