Add an array to ViewState

  • Thread starter Thread starter Gopal Krish
  • Start date Start date
G

Gopal Krish

Folks,

How to add an array to a ViewState in C#?

I'm doing the following and .net does not likes it.

ViewState["HeadingArray"] = HeadingArray;

where HeadingArray is a two dimensional array.

Any thoughts is really appreciated. thanks....

I also tried

ViewState["HeadingArray"] = (object) HeadingArray;

but no use..it still throws error.
 
This doesn't sound like something to put into the viewstate. Does it advise
you to implement a type converter? You could try going that route,
implement a type converter to string-ify your array...
 
It simply says invalid cast....doesn't even give a line number...

What's funny is this works perfectly with one dimension arrays. Only
with two dimensions and more it gives this error.

I have circumvented this problem by using two one dimension arrays for
now.

But still wondering if there is a technical reason behind it.

Thanks...

Damon Payne said:
This doesn't sound like something to put into the viewstate. Does it advise
you to implement a type converter? You could try going that route,
implement a type converter to string-ify your array...

Gopal Krish said:
Folks,

How to add an array to a ViewState in C#?

I'm doing the following and .net does not likes it.

ViewState["HeadingArray"] = HeadingArray;

where HeadingArray is a two dimensional array.

Any thoughts is really appreciated. thanks....

I also tried

ViewState["HeadingArray"] = (object) HeadingArray;

but no use..it still throws error.
 

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

Back
Top