473,396 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

datagrid hidden field not keeping state after postback

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

Nov 19 '05 #1
2 4216
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
"Rodusa" <rc**********@yahoo.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...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

Nov 19 '05 #2
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
Rodusa wrote:
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


Nov 19 '05 #3

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

Similar topics

3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
2
by: andla | last post by:
Hi, How does events fire in a datagrid. I know about the problem if turning the viewstate off the events wil not fire properly even if I rebind the control in every postback. S then I started...
2
by: Mark Rae | last post by:
I've inherited an ASP.NET app and have been asked to fix the following problem with a page which is used to display and/or delete records from a database. When the page loads, it displays a list of...
2
by: Not Me | last post by:
Hi, In a datagrid's itemcommand method, I can use DataGridCommandEventArgs/item/cells/text to bring up a specific field from a row that was accessed. However, I wish to lookup data from that...
6
by: sonic | last post by:
Hi, I am experimenting with different viewstate management ideas for large datagrids, and found a microsoft suggestion to turn it off, and only store relevant information by manually accessing...
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
13
by: Lyners | last post by:
I have a web page writen in ASP.NET that contains some javascript so that when a user presses a button, or edits a certain field in a datagrid, another cell in the datagrid is filled with a value....
3
by: Phillip N Rounds | last post by:
I have a DataGrid in a web form (ASP1.1, C#, VS 2003) that I'm trying to add some functionality to, and I can't figure out how to do int. The existing DataGrid has several databound columns and a...
4
by: WB | last post by:
Hi, I need to validate a hidden input in my webform to ensure that it's got value. The controls look something like this: <input id="HidSelectedStates" type="hidden" runat="server" /><br...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.