473,473 Members | 1,482 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataTable in ViewState

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

Nov 17 '05 #1
3 17129
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" <pr********@hotmail.com> wrote in message
news:uj*************@TK2MSFTNGP10.phx.gbl...
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

Nov 17 '05 #2
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" <sj*****@aboutfortunate.com> wrote in message
news:#i**************@TK2MSFTNGP10.phx.gbl...
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" <pr********@hotmail.com> wrote in message
news:uj*************@TK2MSFTNGP10.phx.gbl...
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


Nov 17 '05 #3
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" <pr********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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" <sj*****@aboutfortunate.com> wrote in message
news:#i**************@TK2MSFTNGP10.phx.gbl...
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" <pr********@hotmail.com> wrote in message
news:uj*************@TK2MSFTNGP10.phx.gbl...
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



Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter...
1
by: Paul Perot | last post by:
Hi All: I have a DataTable that I have defined Globally. I populate this datatable dynamically with file/folder information that I read directly from the server. I use this datatable...
2
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid...
4
by: bijoy | last post by:
My page has a Listbox called Rooms, a text field called chairPerson and a button called Add. When Add is clicked, the script needs to display the selected info in a datagrid. For example, if...
6
by: hitendra15 | last post by:
Hi I have created web user control which has Repeater control and Linkbutton in ItemTemplate of repeater control, following is the code for this control On first load it runs fine but when...
4
by: Jason | last post by:
I have a DataTable from which I am trying to delete rows using the DataGrid control. However, I'm having trouble maintaining the changes to the DataTable between PostBacks. This is my first go...
2
by: DubSport | last post by:
I have created a datatable in a function, and it is populated with data. I want to call a new function from an ASP button, and write out some of the values in the datatable, using: string...
2
by: chike_oji | last post by:
Please can someone help me. I am writing a web application, that allows for the upload of an excel sheet into the database. I have an upload button and a save button. The upload button allows...
5
by: jehugaleahsa | last post by:
Hello: What is the point of using a DataTable in ASP .NET? We are unsure how you can use them without 1) rebuilding them every postback, or 2) taking up precious memory. We are not sure how to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.