473,568 Members | 2,986 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=sel ected&10=select ed&16=selected
....etc

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

objCookie = New HTTPCookie("DRP T-Intranet-Project-Search-ProjMgrs")
objCookie.Expir es = DateTime.MaxVal ue

If chkRememberSett ings.Checked = True Then

'Saving Selected Project Managers
For Each itmProjMgrs In chkProjMgrs.Ite ms

If itmProjMgrs.Sel ected Then
objCookie.Value s(itmProjMgrs.V alue) = "selected"
End If

Next

Else
'Nothing...hope fully, creates an empty cookie
End If

Response.Cookie s.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.Ite ms
'what here? Here's where I need to determine which checkboxes should be
checked..
Next

Nov 18 '05 #1
0 1529

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

Similar topics

17
7221
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 and in the debugger I can see the value I want in the property
3
9293
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, checkbox's and icons are displayed as they are meant to be. My problem is this, I am trying to achieve the same results as I get with CheckListBox(s),...
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 "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...
3
1490
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
4364
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 be really grateful for any assistance! Thanks
3
2300
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 forms authentication. If I create an FormsAuthTicket with userdata in the approprite place. Then encode it and create a cookie, add it to the...
2
16635
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 checklistbox to be checked i want to have all items in the checklistbox to be unchecked. thanks advance, folks.
2
5958
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 possible Thank yo cos7
16
4631
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
1927
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... SELECT DISTINCT fundsAffected as myFunds FROM myFunds AS f INNER JOIN myDetails AS d ON d.corpID = f.corpID WHERE d.securityID = securityID
0
7693
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5217
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.