Viewstate DataGrid problem

G

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

Mohamoss

hi Josema
As you know the view state object has to do with the page so there is one
view for each page. Hence, What you are doing look a bit strange to me so
let me rephrase it.. You are filling the table when the calendar selection
change then you bind that table to the data grid.
If both controls is no the same page, why not binding the datagrid to the
table write away without involving viewstate
If they are not in the same page, why don't you use the session object ( if
there is one table for each user) . Or you can use the application object
if there are only one table for all users of your site.
Application.Add("mytable" ,the_original_table );

Then retrieve your table this way
dataTable retrived = (DataTable)Application.Get("mytable");

You can similarly use the session and the cache object , but you can't use
the viewstate if they are on different pages. Any way you have these other
three options

Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC
 

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

Top