PC Review


Reply
Thread Tools Rate Thread

DataTable in a ViewState

 
 
Pradeep
Guest
Posts: n/a
 
      26th Aug 2003
Hi,

I am storing the DataTable in a ViewState.

ViewState("mydata") = dsRedemption.T_Redemption_Dtl

Then I am casting the ViewState into a DataTable variable.

Dim x As New DataTable
x = CType( ViewState("mydata"), DataTable)

This is giving me a error where it's not allowing me to Cast it. If i
directly see the data in the ViewState("mydata") it's perfectly fine. First
of all, is it advisable to store the DataTable in the ViewState ???

Any idea ???

Pradeep


 
Reply With Quote
 
 
 
 
John Viele
Guest
Posts: n/a
 
      26th Aug 2003
First, I am a C# guy, and second, I have only done this with a DataSet, not
a DataTable, but in principle it should work equally well.

However, if your DataTable object is fairly large, it will make your page
load quite slowly (all of that data to construct your data table must be
piped across as part of the page's data). You could consider using a
Session variable so that it remains on the server. That will eat up server
memory, but it won't take the same performance hit on page loading.

Only other thing I noticed was this:
>>> Dim x As New DataTable ' This actually instantiates an empty

DataTable object

Now, as I said, I am a C# guy, not a VB guy, but I don't think this should
cause the typecasting error. However, it does waste some time instantiating
a DataTable object that you are just going to replace with the next
statement. If I remember VB correctly, you may just want the following:
>>> Dim x as DataTable



"Pradeep" <(E-Mail Removed)> wrote in message
news:e9ruUi%(E-Mail Removed)...
> Hi,
>
> I am storing the DataTable in a ViewState.
>
> ViewState("mydata") = dsRedemption.T_Redemption_Dtl
>
> Then I am casting the ViewState into a DataTable variable.
>
> Dim x As New DataTable
> x = CType( ViewState("mydata"), DataTable)
>
> This is giving me a error where it's not allowing me to Cast it. If i
> directly see the data in the ViewState("mydata") it's perfectly fine.

First
> of all, is it advisable to store the DataTable in the ViewState ???
>
> Any idea ???
>
> Pradeep
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ViewState and DataTable Peter Hemmingsen Microsoft ASP .NET 1 4th Jan 2010 11:53 AM
Datatable in ViewState... why does this work? cmay Microsoft ASP .NET 5 14th Jul 2005 03:19 PM
Add DataTable to ViewState Kiran Microsoft ASP .NET 1 25th Jan 2005 04:46 PM
DataTable in ViewState Pradeep Microsoft ASP .NET 3 27th Aug 2003 03:24 PM
Insert a Datatable or Datagrid into ViewState? Stephajn Craig Microsoft ASP .NET 1 23rd Jul 2003 01:29 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:02 PM.