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

Retaining Checkbox values during postback (ASPX)


I have a page with several server controls placed on there at design
time, including a blank table control.

During runtime I add some controls to the table, including some
checkboxes, which I called ch() as checkbox. the user would then
check some of them and click a button.

the event handler for the button would save the checkbox checked state
to a database.
but as soon as the button is clicked, ch() is nothing. all the other
design time controls have retained their values, but not the
checkboxes.

Scott
Mar 16 '06 #1
1 3946
First, do these checkboxes have EnableViewState=True? Do all of their parent
Controls have EnableViewState=True? If they do, you can try adding some code
to the Page.Load event that reads the checked state from the database so
that each time the page loads it sets the checked state to whatever the user
selected the last time. If you don't want to have to go to the trouble of
reading from the database, you could use Cookies or Session variables and
only worry about reading the database for long-term purposes, it all depends
on exactly what your site is used for. If you need help figuring out how to
do any of these things feel free to ask. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Scott H" <x@x.com> wrote in message
news:bm********************************@4ax.com...

I have a page with several server controls placed on there at design
time, including a blank table control.

During runtime I add some controls to the table, including some
checkboxes, which I called ch() as checkbox. the user would then
check some of them and click a button.

the event handler for the button would save the checkbox checked state
to a database.
but as soon as the button is clicked, ch() is nothing. all the other
design time controls have retained their values, but not the
checkboxes.

Scott

Mar 16 '06 #2

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

Similar topics

0
by: Earl Teigrob | last post by:
I have a page that reads values from an XML file to display to the user. The page also has a control panel that allows administrators to update the XML file with new values. When an administrator...
5
by: Greg Hurlman | last post by:
I've got a very simple ASCX page, where once someone finishes a section and clicks the "Next >" button, the section they just finished is disabled, and the next section appears below it, and so on....
3
by: eSapient | last post by:
I created a web page which contains a form which contains a table. The number of rows for the table are determined dynamically. The first cell of each row contains a HyperLink control and the last...
3
by: Mark | last post by:
Hi, I have an aspx page, that in the PageLoad sub, gets values from a specific record in a database as where the record id is retrieved from the querystring. Thesee values are then used to...
1
by: mschoup | last post by:
I have a simple aspx page(WebForm1.aspx) with a HyperLink, LinkButton, and two CheckBoxes. When I select a CheckBox and then click the LinkButton, the CheckBox retains state. When I select the...
2
by: dilip.movva | last post by:
Hi, In the ItemDataBound of my datagrid I am creating a checkbox dynamically. I have the eventhandler defined for CheckedChanged of the check box. The event is not firing. The grid is bound in the...
0
by: deathtospam | last post by:
A few weeks ago, I created a Classic ASP page that connects to a machine with SQL Server installed on it, prompts the user to select a database on that server, then lists all of user-created stored...
3
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
Hi, Trouble in retaining values of dropdownlist, textboxes, and other controls when dropdownlist selectedindexchanged event is triggered, the controls are inside a user control and this user...
2
by: ton | last post by:
Hi, I have a checkbox in a webserver control. Al modified fields (textboxes, dropdownlists, and checkboxes) will be examnied during a save method. In which I use: aa=...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: 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...

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.