ViewState problems for inherited TreeNode class. (2.0 framework)

Discussion in 'ASP .Net Web Controls' started by ketan.shah@gmail.com, Nov 3, 2005.

  1. Guest

    I inherited the TreeNode since I wanted to get more attributes into the
    checkbox. So I create my own checkbox on PreRenderText(). The problem
    now is that I want to save the state of the attributes so that on a
    page postback, I can get the checkbox in the same state as it was
    before the the postback. I started by overriding the SaveViewState()
    (by adding the attribute values to the arraylist provided by the
    base.SaveViewState object) and LoadViewState() methods. The problem I
    am facing is that if I add the attributes to the saveviewstate object,
    they are not persisted in the next postback. Also, the LoadViewState()
    method is never called. Could anyone please point out if I am missing
    something?


    Here is the code snippet for the SaveViewState()

    =======================================
    protected override object SaveViewState()
    {
    object[] viewState = base.SaveViewState() as object[];
    ArrayList list = viewState[0] as ArrayList; // getting the
    arraylist where the default values were stored.
    list.Add(this._state); ------> adding my attribute to the
    view state object.
    return (viewState as object);
    }

    =======================================

    Thanks,
    -K.
     
    , Nov 3, 2005
    #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. leal ting
    Replies:
    1
    Views:
    510
    Bryan Donaldson
    Feb 10, 2004
  2. tanya foster
    Replies:
    3
    Views:
    3,742
    tanya foster
    May 18, 2006
  3. Bernhard Wurm

    Inherited TreeNode

    Bernhard Wurm, Sep 8, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    125
    Bernhard Wurm
    Sep 8, 2005
  4. Keith Patrick

    Customizing a TreeNode's viewstate

    Keith Patrick, Jan 3, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    195
    Keith Patrick
    Jan 3, 2006
  5. 7stud --
    Replies:
    11
    Views:
    416
    7stud --
    Nov 9, 2007
Loading...

Share This Page