PC Review


Reply
Thread Tools Rate Thread

DataTable in 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
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      26th Aug 2003
Pradeep,

Depending on the size of the table it could make for a very slow load of
your page on the client, but other than watching the table's size it should
be fine.

Now .Net might be getting confused because when you save the table to
viewstate you are referencing it through the dataset it's in. Perhaps it
thinks you are saving the entire dataset?

Try setting the table to a new container and then saving that container to
viewstate:

Dim MyDataTable As DataTable = dsRedemption.T_Redemption_Dtl

ViewState("mydata") = MyDataTable

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

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche


"Pradeep" <(E-Mail Removed)> wrote in message
news:ujNkCn$(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
 
Pradeep
Guest
Posts: n/a
 
      27th Aug 2003
Hi Justin,

Now I am trying to store the DataTable into a new contrainer and then to the
ViewState. This time it doesn't raise any error. But after casting, my "x"
value is becoming "Nothing" even though data is available in the ViewStage
variable.

Where is the problem ???

Pradeep

"S. Justin Gengo" <(E-Mail Removed)> wrote in message
news:#i$(E-Mail Removed)...
> Pradeep,
>
> Depending on the size of the table it could make for a very slow load of
> your page on the client, but other than watching the table's size it

should
> be fine.
>
> Now .Net might be getting confused because when you save the table to
> viewstate you are referencing it through the dataset it's in. Perhaps it
> thinks you are saving the entire dataset?
>
> Try setting the table to a new container and then saving that container to
> viewstate:
>
> Dim MyDataTable As DataTable = dsRedemption.T_Redemption_Dtl
>
> ViewState("mydata") = MyDataTable
>
> Dim x As New DataTable
> x = CType( ViewState("mydata"), DataTable)
>
> Sincerely,
>
> --
> S. Justin Gengo, MCP
> Web Developer
>
> Free code library at:
> www.aboutfortunate.com
>
> "Out of chaos comes order."
> Nietzche
>
>
> "Pradeep" <(E-Mail Removed)> wrote in message
> news:ujNkCn$(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
 
S. Justin Gengo
Guest
Posts: n/a
 
      27th Aug 2003
Pradeep,

I should have noticed this originally. When you dim x don't dim it as "New"

Dim x As DataTable

x = CType(ViewState("MyData"), DataTable)

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche


"Pradeep" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi Justin,
>
> Now I am trying to store the DataTable into a new contrainer and then to

the
> ViewState. This time it doesn't raise any error. But after casting, my

"x"
> value is becoming "Nothing" even though data is available in the ViewStage
> variable.
>
> Where is the problem ???
>
> Pradeep
>
> "S. Justin Gengo" <(E-Mail Removed)> wrote in message
> news:#i$(E-Mail Removed)...
> > Pradeep,
> >
> > Depending on the size of the table it could make for a very slow load of
> > your page on the client, but other than watching the table's size it

> should
> > be fine.
> >
> > Now .Net might be getting confused because when you save the table to
> > viewstate you are referencing it through the dataset it's in. Perhaps it
> > thinks you are saving the entire dataset?
> >
> > Try setting the table to a new container and then saving that container

to
> > viewstate:
> >
> > Dim MyDataTable As DataTable = dsRedemption.T_Redemption_Dtl
> >
> > ViewState("mydata") = MyDataTable
> >
> > Dim x As New DataTable
> > x = CType( ViewState("mydata"), DataTable)
> >
> > Sincerely,
> >
> > --
> > S. Justin Gengo, MCP
> > Web Developer
> >
> > Free code library at:
> > www.aboutfortunate.com
> >
> > "Out of chaos comes order."
> > Nietzche
> >
> >
> > "Pradeep" <(E-Mail Removed)> wrote in message
> > news:ujNkCn$(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 10:53 AM
Datatable in ViewState... why does this work? cmay Microsoft ASP .NET 5 14th Jul 2005 02:19 PM
Add DataTable to ViewState Kiran Microsoft ASP .NET 1 25th Jan 2005 03:46 PM
DataTable in a ViewState Pradeep Microsoft ADO .NET 1 26th Aug 2003 10:02 PM
Insert a Datatable or Datagrid into ViewState? Stephajn Craig Microsoft ASP .NET 1 23rd Jul 2003 12:29 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:21 PM.