473,378 Members | 1,482 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.

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 1497

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

Similar topics

17
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
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
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
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
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
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
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
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
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
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
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
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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.