Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > textbox text missing after detailsview postback?

Reply
Thread Tools

textbox text missing after detailsview postback?

 
 
News User
Guest
Posts: n/a
 
      07-31-2006
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.


 
Reply With Quote
 
 
 
 
News User
Guest
Posts: n/a
 
      07-31-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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.
>
>



 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      07-31-2006
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>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.
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Textbox, Input (text) on turbotax... anyone know which 3rd party textbox this is??? pld888@gmail.com ASP .Net 3 02-23-2007 08:51 PM
Textbox.text inside detailsview returning empty dharric ASP .Net 0 10-24-2006 07:50 PM
DetailsView - Changing to Insert Mode (Not By Using the Insert Button In the DetailsView Control) Feege ASP .Net Web Controls 0 12-20-2005 12:28 AM
ASP.NET textbox loses text value in composite control but Textbox subclass doesn't!? ErwinP ASP .Net Web Controls 1 08-19-2005 01:50 PM
writing two textbox's text in one textbox agb ASP .Net Web Controls 1 08-27-2003 12:57 AM



Advertisments