473,503 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looking in a cookie collection to preselect checklistbox items

I have a form with a CheckBoxList which is created from a SQLDataReader. It
contains Staff personnel and I use the ID and LogOnName (a string) to build
the CBL. All works fine. I also have a "Remember my settings" checkbox on
the form that if checked, will run a sub routine to create a cookie to store
the IDs of the checked names in the CBL. The idea is to have the form
"remember" the user's selections so when they come back to the form at a
later time, their checkboxes are filled in for them and they can just click
Submit.

I can create the cookie just fine. But I'm having trouble with creating the
logic to look "in" the cookie to look for any Staff IDs to preselect the
checkboxes. In theory, I could after the databinding of the CBL, I could
then loop thru all the CBL Items and see if it's found in the cookie, if so,
simply check the checkbox and move to the next item. Etc.

Make sense? So how do I look in the cookie and make that connection??

The contents of my sample cookie:

DRPT-Intranet-Project-Search-ProjMgrs|12=selected&10=selected&16=selected
....etc

'****************************************
Sub CreateCookie()
Dim objCookie As HTTPCookie
Dim itmProjMgrs As ListItem

objCookie = New HTTPCookie("DRPT-Intranet-Project-Search-ProjMgrs")
objCookie.Expires = DateTime.MaxValue

If chkRememberSettings.Checked = True Then

'Saving Selected Project Managers
For Each itmProjMgrs In chkProjMgrs.Items

If itmProjMgrs.Selected Then
objCookie.Values(itmProjMgrs.Value) = "selected"
End If

Next

Else
'Nothing...hopefully, creates an empty cookie
End If

Response.Cookies.Add(objCookie)

End Sub
'****************************************
And this is within a sub I use to build the CheckBoxList from a
SQLDataReader:
....etc

objCookie = Request.Cookies("DRPT-Intranet-Project-Search-ProjMgrs")

For Each itmProjMgrs In chkProjMgrs.Items
'what here? Here's where I need to determine which checkboxes should be
checked..
Next

Nov 18 '05 #1
0 1516

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

Similar topics

17
7216
by: James Johnson | last post by:
Dear C#dex, I define a variable: HttpWebRequest webRequest and run the following request webRequest = WebRequest.Create(TARGET_URL) as HttpWebRequest; The webRequest object returns values...
3
9284
by: MikeY | last post by:
Hopefully someone can help me on this. I am using C#, making Windows forms. I have created a listView with checkbox's. I have enabled the checkboxes under the properties, and all the data,...
0
280
by: D. Shane Fowlkes | last post by:
I have a form with a CheckBoxList which is created from a SQLDataReader. It contains Staff personnel and I use the ID and LogOnName (a string) to build the CBL. All works fine. I also have a...
3
1483
by: Mau | last post by:
I have a big problem with the CheckListBox control: if I disable it and the I enable it I loose selection (checking) , why? There is a way to solve this? Tanks M Here some code:
3
4363
by: Tim::.. | last post by:
Can someone please tell me how I go about preselecting an item in a drop drown list when I click the Edit Command in a datagrid? I have tried the following but it doesn't work for me! I would...
3
2296
by: chuck rudolph | last post by:
Folks, Can anyone confirm that my understading is correct and maybe shed some light on why it's as it is. (I'm guessing security, but that seems weak to me.) The asp.net web application is using...
2
16610
by: Mike Kim | last post by:
hi all, i have a checklistbox populated with about 50 items from database. and on the same form, i added to button to do the following. if you click this button, i want to have all items in the...
2
5953
by: cos75 | last post by:
When I populate a checklistbox with Add method every item is showed equal to the others I would show some item enabled, and some disabled......some item in black text and others in red text Is...
16
4617
by: MSN | last post by:
xp pro/vs 2002/web forms/VB How do I make a checkbox checked when add it to a checkboxlist. Thanks
1
1923
by: obrienkev | last post by:
Hi, I want to mark the CheckListBox items as Checked based on a database query. So the CheckListBox items should be checked if each item matches fundsAffected field from the below query... ...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7076
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7274
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5576
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5005
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4670
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
377
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.