473,378 Members | 1,415 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,378 software developers and data experts.

viewstate = false doesn't work

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
Jun 21 '07 #1
2 2186
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
"Dica" <ge*****@hotmail.coma écrit dans le message de news:
%Wxei.6081$xk5.4250@edtnps82...
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

Jun 21 '07 #2

"Patrice" <http://www.chez.com/scribe/wrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
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
"Dica" <ge*****@hotmail.coma écrit dans le message de news:
%Wxei.6081$xk5.4250@edtnps82...
>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


Jun 22 '07 #3

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

Similar topics

9
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter...
3
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
1
by: Lisa | last post by:
I have a web app that gets a recordset from the database and fills a grid. You can drilldown from this table to a detail table. Because the tables sometimes get huge, and because I have to go...
1
by: olduncleamos | last post by:
Hello all, I am experimenting with the repeater control and ran into something that I wasn't expecting. I would appreciate if the experts can confirm or correct my understanding. Here is a...
6
by: John | last post by:
Hi all, I am using dynamic user controls within my web app and these controls are loaded into placeholders via the LoadControl method. My problem is this: I have usercontrolA loaded into a...
4
by: Sven Jacobs | last post by:
Hello everybody! Imagine a form with several TextBox WebControls and two buttons "New" which should clear the form and "Save". On reloading or leaving the page which holds the form the TextBoxes...
10
by: Robert | last post by:
I have an app that was originally 1.1, now migrated to 2.0 and have run into some sporadic viewstate errors...usually saying the viewstate is invalid, eventvalidation failed or mac error. My web...
10
by: Lloyd Dupont | last post by:
When you define UserControl in source code the sample I see are often like that: ============ public string Text { get { String s = (String)ViewState; return ((s == null) ? String.Empty : s);...
1
by: Christophe Peillet | last post by:
I have a CompositeControl with two types of properties: 1.) Mapped Properties that map directly to a child control's properties (ex.: this.TextboxText = m_txt.Text). These properties are handled...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.