textbox text missing after detailsview postback?

Discussion in 'ASP .Net Datagrid Control' started by News User, Jul 31, 2006.

  1. News User

    News User Guest

    I have a imagebutton in a detailsview, which, when clicked, causes postback
    and show or hide some of the rows. (Me.DetailsView1.Fields(4).Visible = true
    or false) That's all it does.

    In the same detailsview I have other controls : dropdownlist, checkbox and
    textboxes etc., all of them are bound to database fields when page is
    loaded.

    When I changed the values in the dropdownlist/checkbox/textbox, and then
    click the imagebutton to show/hide some other rows, all the changes I made
    to the dropdownlist/checkbox/textbox are gone (restored to its original
    bound value) after postback.

    I commented the code that does the show/hide of rows, and found that the
    values of dropdownlist/checkbox/textbox are preserved after postback.

    So I wonder if this is normal -- when a row in a detailsview is dynamically
    made shown or hidden, then the whole detailsview will have to be databound
    again, causing all controls inside this detailsview to retored its original
    bound value.

    Thanks.
     
    News User, Jul 31, 2006
    #1
    1. Advertising

  2. News User

    News User Guest

    I just found a workaround:
    I had to save the updated information in ViewState, and then during
    postback, assign the controls with the values saved in ViewState.



    "News User" <> wrote in message
    news:...
    >I have a imagebutton in a detailsview, which, when clicked, causes postback
    >and show or hide some of the rows. (Me.DetailsView1.Fields(4).Visible =
    >true or false) That's all it does.
    >
    > In the same detailsview I have other controls : dropdownlist, checkbox and
    > textboxes etc., all of them are bound to database fields when page is
    > loaded.
    >
    > When I changed the values in the dropdownlist/checkbox/textbox, and then
    > click the imagebutton to show/hide some other rows, all the changes I made
    > to the dropdownlist/checkbox/textbox are gone (restored to its original
    > bound value) after postback.
    >
    > I commented the code that does the show/hide of rows, and found that the
    > values of dropdownlist/checkbox/textbox are preserved after postback.
    >
    > So I wonder if this is normal -- when a row in a detailsview is
    > dynamically made shown or hidden, then the whole detailsview will have to
    > be databound again, causing all controls inside this detailsview to
    > retored its original bound value.
    >
    > Thanks.
    >
    >
     
    News User, Jul 31, 2006
    #2
    1. Advertising

  3. It may help you, if you realize that web controls with Visible=false don't
    get sent to the client and, naturally, don't bring their values back to
    server on postbacks. If you are interested in hidden data either on client
    or after postbacks, you should hide controls with css rule display:hidden
    and leave Visible=true.
    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]

    "News User" <> wrote in message
    news:%...
    >I just found a workaround:
    > I had to save the updated information in ViewState, and then during
    > postback, assign the controls with the values saved in ViewState.
    >
    >
    >
    > "News User" <> wrote in message
    > news:...
    >>I have a imagebutton in a detailsview, which, when clicked, causes
    >>postback and show or hide some of the rows.
    >>(Me.DetailsView1.Fields(4).Visible = true or false) That's all it does.
    >>
    >> In the same detailsview I have other controls : dropdownlist, checkbox
    >> and textboxes etc., all of them are bound to database fields when page is
    >> loaded.
    >>
    >> When I changed the values in the dropdownlist/checkbox/textbox, and then
    >> click the imagebutton to show/hide some other rows, all the changes I
    >> made to the dropdownlist/checkbox/textbox are gone (restored to its
    >> original bound value) after postback.
    >>
    >> I commented the code that does the show/hide of rows, and found that the
    >> values of dropdownlist/checkbox/textbox are preserved after postback.
    >>
    >> So I wonder if this is normal -- when a row in a detailsview is
    >> dynamically made shown or hidden, then the whole detailsview will have to
    >> be databound again, causing all controls inside this detailsview to
    >> retored its original bound value.
    >>
    >> Thanks.
    >>
    >>

    >
    >
     
    Eliyahu Goldin, Jul 31, 2006
    #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. dharric
    Replies:
    0
    Views:
    671
    dharric
    Oct 24, 2006
  2. zhixuen
    Replies:
    0
    Views:
    1,244
    zhixuen
    Feb 10, 2009
  3. Elroyskimms

    Accessing Textbox Text After Postback in Dynamic Control

    Elroyskimms, Feb 20, 2006, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    491
    Jose Rodriguez
    Feb 22, 2006
  4. dave

    Control missing property after postback with repeater

    dave, Aug 1, 2006, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    156
  5. Feege
    Replies:
    0
    Views:
    494
    Feege
    Dec 20, 2005
Loading...

Share This Page