DataGrid Viewstate problem

Discussion in 'ASP .Net Building Controls' started by Josema, May 20, 2004.

  1. Josema

    Josema Guest

    Hi, to all..

    I have 2 web controls (MyDataGrid.cs, MyCalendar.cs

    The first inherits from calendar, and i have implemented the event MyCalendar_SelectionChanged and inside of this i put in the viewstate a datatable that i filled (and its filled, i verified)... like this

    Viewstate.Add("DATA", MyDataTable)

    The second inherits from DataGrid, and i override the On_Load in the control and inside this i have

    this.DataSource=Viewstate["DATA"]
    this.DataBind()

    But doesnt ocurr nothing... Im doing well the use of the viewstate?..

    Thanks very much.

    Josema.
    Josema, May 20, 2004
    #1
    1. Advertising

  2. Josema

    Teemu Keiski Guest

    Hi,

    maybe it would be because SelectionChanged event is raised after Load event
    (SelectionChanged is a postback event and occurs after Load events) e.g when
    your dataGrid is to be data-bound there isn't anything in ViewState yet. Do
    you check for isPostBack when binding DataGrid?

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke

    "Josema" <> wrote in message
    news:...
    > Hi, to all...
    >
    > I have 2 web controls (MyDataGrid.cs, MyCalendar.cs)
    >
    >
    > The first inherits from calendar, and i have implemented the event

    MyCalendar_SelectionChanged and inside of this i put in the viewstate a
    datatable that i filled (and its filled, i verified)... like this:
    >
    > Viewstate.Add("DATA", MyDataTable);
    >
    > The second inherits from DataGrid, and i override the On_Load in the

    control and inside this i have:
    >
    > this.DataSource=Viewstate["DATA"];
    > this.DataBind();
    >
    > But doesnt ocurr nothing... Im doing well the use of the viewstate?...
    >
    > Thanks very much..
    >
    > Josema.
    Teemu Keiski, May 28, 2004
    #2
    1. Advertising

  3. Josema

    Natty Gur Guest

    Hi,

    I don't think that you using ViewState correctly. Control should
    implement IStateManager to support ViewState and it suppose to maintain
    control own state (not other control state).

    I don't know what exactly you after but probably calendar control should
    implement property that other controls can call to obtain data. I don't
    like this solution either, because any control should maintain its own
    data and not others.


    Natty Gur[MVP]

    blog : http://weblogs.asp.net/ngur
    Mobile: +972-(0)58-888377


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur, May 28, 2004
    #3
    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. Ben Rush
    Replies:
    2
    Views:
    505
    Ben Rush
    Dec 5, 2003
  2. Steph
    Replies:
    2
    Views:
    1,646
    heislord5
    May 11, 2011
  3. ujjc001
    Replies:
    0
    Views:
    1,362
    ujjc001
    Jul 27, 2005
  4. sck10
    Replies:
    6
    Views:
    901
    sck10
    Sep 1, 2006
  5. mark

    Viewstate errors... how do I get viewstate working?

    mark, Feb 20, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    268
Loading...

Share This Page