datagrid hidden field not keeping state after postback

Discussion in 'ASP .Net' started by Rodusa, Feb 11, 2005.

  1. Rodusa

    Rodusa Guest

    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
     
    Rodusa, Feb 11, 2005
    #1
    1. Advertising

  2. Rodusa

    Max Guest

    > 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" <> wrote in message
    news:...
    >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
    >
     
    Max, Feb 11, 2005
    #2
    1. Advertising

  3. Rodusa

    Rodusa Guest

    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
     
    Rodusa, Feb 15, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGF1bCBSZWVk?=

    Hidden Text Field Occasionally Missing Data on Postback

    =?Utf-8?B?UGF1bCBSZWVk?=, Sep 24, 2007, in forum: ASP .Net
    Replies:
    6
    Views:
    604
    =?Utf-8?B?UGF1bCBSZWVk?=
    Sep 25, 2007
  2. Rick
    Replies:
    3
    Views:
    8,218
    Alexey Smirnov
    Apr 13, 2010
  3. David Wyn Davies

    Dropdownlist not keeping viewstate after postback

    David Wyn Davies, May 27, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    346
  4. GavMc
    Replies:
    4
    Views:
    350
    Evertjan.
    Sep 22, 2005
  5. Roy Adams

    writing from hidden field to text field

    Roy Adams, Dec 20, 2004, in forum: Javascript
    Replies:
    1
    Views:
    203
Loading...

Share This Page