asp:table remembering state?

Discussion in 'ASP .Net Web Controls' started by Davey P, Jun 9, 2005.

  1. Davey P

    Davey P Guest

    I have an asp.net table which I am populating with controls dynamically at
    runtime. The controls themselves get/set values in a datatable which is
    stored in viewstate over postbacks. Here is basically what I am doing:

    pull datatable out of viewstate

    for each row in datatable
    create tablerow
    create tablecells
    create controls
    get data items from datatable and place the values in the controls
    add controls to tablecells
    add tablecells to tablerow
    add tablerow to asp table

    draw the control

    I save values back to the datatable in a similar way, but instead scroll
    through the rows in the asp table and place the values in the appropriate
    datatable item.
    This all works fine, but the problem is with deleting a row. I simply delete
    the desired row from the datatable and then call my table creation method
    described above. This should surely mean that the asp table will not display
    the row as it no longer exists in the datatable. But what happens is that a
    row is deleted, but all the ones below it "bubble up" in that they take on
    the previous rows value. So it seems as if the bottom row has been removed.
    I've checked my datatable and the values in here don't correspond with whats
    being displayed. Is there some form of caching going on that I'm not seeing?
    ViewState is turned off for the asp table and hence all of its controls.

    Any ideas?!!!

    (p.s. sorry for the long description, but I thought I'd try and give you a
    clear picture of whats going on)
     
    Davey P, Jun 9, 2005
    #1
    1. Advertising

  2. Davey P

    Guest

    Hi Davey,

    Items in ViewState get saved in order. If you get rid of items, that
    doesn't change. And I'm not 100% sure that turning off ViewState for
    the table is going to turn it off for the controls in the cells.

    Try this: http://www.wilsondotnet.com/Demos/ViewState.aspx

    This is a ViewState parser. It doesn't tell you the names of the
    controls, because, as I said, it relies completely on the order in
    which they are saved to ViewState and loaded from ViewState. But if
    you have values in the controls, odds are you'll be able to figure out
    what's what.

    At the very least, should all else fail, you could simply hide rows
    instead of deleting them. Setting Visible = False will keep them from
    being rendered, but will preserve the order for your ViewState. Of
    course, if you decide to try sorting the rows, that wouldn't help you
    anymore, but you haven't said anything about doing that.

    Lisa


    Davey P wrote:
    > I have an asp.net table which I am populating with controls dynamically at
    > runtime. The controls themselves get/set values in a datatable which is
    > stored in viewstate over postbacks. Here is basically what I am doing:
    >
    > pull datatable out of viewstate
    >
    > for each row in datatable
    > create tablerow
    > create tablecells
    > create controls
    > get data items from datatable and place the values in the controls
    > add controls to tablecells
    > add tablecells to tablerow
    > add tablerow to asp table
    >
    > draw the control
    >
    > I save values back to the datatable in a similar way, but instead scroll
    > through the rows in the asp table and place the values in the appropriate
    > datatable item.
    > This all works fine, but the problem is with deleting a row. I simply delete
    > the desired row from the datatable and then call my table creation method
    > described above. This should surely mean that the asp table will not display
    > the row as it no longer exists in the datatable. But what happens is that a
    > row is deleted, but all the ones below it "bubble up" in that they take on
    > the previous rows value. So it seems as if the bottom row has been removed.
    > I've checked my datatable and the values in here don't correspond with whats
    > being displayed. Is there some form of caching going on that I'm not seeing?
    > ViewState is turned off for the asp table and hence all of its controls.
    >
    > Any ideas?!!!
    >
    > (p.s. sorry for the long description, but I thought I'd try and give you a
    > clear picture of whats going on)
     
    , Jun 10, 2005
    #2
    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:
    3
    Views:
    783
    Justin Lovell
    Oct 5, 2003
  2. =?Utf-8?B?RGF2ZXkgUA==?=

    asp:table remembering state!?

    =?Utf-8?B?RGF2ZXkgUA==?=, Jun 9, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    369
    =?Utf-8?B?RGF2ZXkgUA==?=
    Jun 9, 2005
  3. =?Utf-8?B?QmlsbCBNYW5yaW5n?=

    Remembering the state of a Page

    =?Utf-8?B?QmlsbCBNYW5yaW5n?=, Sep 6, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    442
  4. Piotrek \Alchemik\
    Replies:
    0
    Views:
    310
    Piotrek \Alchemik\
    Nov 12, 2006
  5. anathema

    Remembering a boxes state with a cookie.

    anathema, Jan 23, 2007, in forum: Javascript
    Replies:
    1
    Views:
    106
    getburl
    Jan 23, 2007
Loading...

Share This Page