Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

viewstate = false doesn't work

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dica - 21 Jun 2007 17:45 GMT
i've got a simple page with a dropdown list of employees and a series of
checkboxs showing their skills. the checkboxs are created dynamically from a
sql statement and viewstate = false is set on each one. once the dropdown
changes from one employee to another, the checkboxes are all recreated and i
check the database to see if that particular employee has that skill. if so,
i set the checkbox's checked state to true. however, when i look at the
newly rendered page, the only checkboxs that are checked are those that i've
manully checked. i could set the viewstate in the page directive, but that
applies to all controls and i want the page to remember which employee was
last selected.

so, it looks like my script is initializing the checkboxes to the correct
value initially, but after that .net steps in and sets them back to what was
last posted even though i've set viewstate to all checkbox controls to
false.

anybody got any ideas what i'd doing wrong here?

tks
Patrice - 21 Jun 2007 18:10 GMT
Field values are not stored in the viewstate. By design a web page post
field values to the server. The viewstate was created to store other values.
So IMO your controls are just reinitialized from postback values.

Double check your code. You likely forgot to initialize the values from the
db after a postback ( it's likely that usually you don't bind again on a
postback because the data are what you want to show but in this particular
case the postback change the current set of data you wan't to display so you
should bind again to your data).

--
Patrice

> i've got a simple page with a dropdown list of employees and a series of
> checkboxs showing their skills. the checkboxs are created dynamically from
[quoted text clipped - 15 lines]
>
> tks
Dica - 22 Jun 2007 13:57 GMT
> Field values are not stored in the viewstate. By design a web page post
> field values to the server. The viewstate was created to store other
> values. So IMO your controls are just reinitialized from postback values.

yes. that's exactly what i'm seeing. what i'm trying to do is stop the asp
net engine from repopulating these fields based on the posted back data and
instead use the values i'm assigning as the dynamically created controls are
initialized. i modified my page so that when the user drop down list is
changed (causing a postback event) i capture the selected user to session
and then response.redirect back to the same page. then, within page_load i
get the selected user and call my routine to recreate the dynamic controls
with the appropriate values. this works fine. so, it's something in the
postback event i need to control, but how? if the solution is to rebind my
data, in which event handler should it go? in other words, which event would
fire after .net is done repopulating the form fields?

tks

> Double check your code. You likely forgot to initialize the values from
> the db after a postback ( it's likely that usually you don't bind again on
> a postback because the data are what you want to show but in this
> particular case the postback change the current set of data you wan't to
> display so you should bind again to your data).

> --
> Patrice
[quoted text clipped - 18 lines]
>>
>> tks

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.