DataGrid Viewstate problem

J

Josema

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.
 
T

Teemu Keiski

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 said:
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.
 
N

Natty Gur

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top