datagrid hidden field not keeping state after postback

R

Rodusa

I have a hidden field inside one datagrid which I can't get to make it
keep its state after a postback event.
Look field:

<input type="hidden" id="TxtHiddenItem_id" name="TxtHiddenItem_id"
runat="server" value='<%# DataBinder.Eval(Container,
"DataItem.item_id").ToString() %>'>


I can get around that using an asp.net textbox control, but it doesn't
work well with large strings.

I don't know if it has to do with the fact that a hidden field is not
really 100% an asp.net control. The way I am changing the hidden field
value is by using javascript document.all("myfield").value;

Rod
 
M

Max

The way I am changing the hidden field
value is by using javascript document.all("myfield").value;

I could be wrong, but that's probably why it's not working. My assumption is
that the runtime ignores changes to hidden fields on post back. This is
probably because the data in a hidden field is only known to the runtime as
coming from the viewstate -- not the from field itself. Your javascript
isn't going to be able to disect and modify the viewstate variable, so if
you could explain what you're trying to do, there is probably a better
method someone could point to.

-Max
 
R

Rodusa

I have a datagrid with a couple of texboxes and labels. The textboxes
maintain the state properly after I update their values and postback.
However, the asp.net label and hidden fields do not maintain their
values. It always keeps the old value. Like I said the textbox works,
but I don't want to use textbox for all columns because I would have to
limit their size and I want to avoid that in certain cases, for
example, on calculated fields, and on the part number column. So, far,
I can't see any other solution for this. If you want to test that, just
add a <input type="hidden" runat="server" or a <asp:label and change
its value with javascript usinig document.all("the field").value, then
try posting back. Then, do the same using a <asp:TextBox

thanks

Rod
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top