Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Looking in a cookie collection to preselect checklistbox items

Reply
Thread Tools

Looking in a cookie collection to preselect checklistbox items

 
 
D. Shane Fowlkes
Guest
Posts: n/a
 
      04-07-2004
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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Řyvind Isaksen ASP .Net 1 05-18-2007 09:24 AM
Can preselect databound listbox items Joel Barsotti ASP .Net Web Controls 0 01-04-2007 09:04 PM
How can I get selected Checklistbox Items to Literal in Placeholde Christiaan Nieuwlaat ASP .Net Web Controls 3 05-30-2005 05:55 PM
Preselect item in DropdownList Edit mode??? =?Utf-8?B?VGltOjouLg==?= ASP .Net 3 12-29-2004 06:01 AM
How to preselect multiple items in listbox Isaac Wang via .NET 247 ASP .Net 1 04-27-2004 05:21 PM



Advertisments