Looking in a cookie collection to preselect checklistbox items

  • Thread starter D. Shane Fowlkes
  • Start date
D

D. Shane Fowlkes

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top