ViewState error and DataGrid loses its content

T

Tumurbaatar S.

My web user control (ASCX) consists of one DataGrid and several
web user controls (ASCX). On page postback, the DataGrid loses
its content: row/item information, i.e. cells text. Other user controls
(and standard controls too) do not lose theirs text.
I checked ViewState value of the page with the ViewStateDecoder (
v1.1, by Fritz Onion) and found that something wrong with ViewState.
The decoder raises an error:
There was an error decoding the ViewState string: Key cannot be null.
Parameter name: key

Any ideas?

P.S. I've not tested it, but may be, this happens because I use controls in
items.
For example, on ItemDataBound event:
I do so
e.Item.Cells.Controls.Add(new LiteralControl("some text"))
instead of
e.Item.Cells.Text = "some text";

I use LiteralControl instead of cells Text because I need to insert
break tags (<br>) within cells. Is there a way to do this without
LiteralControl?
 

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

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top