My CheckBoxList is named cbAvail - and I have a comma delimmited list in a sesion variable "activitywhentext" which holds the text of the checkbox. I am trying to iterate through the comma list, find the checkbox item which relates to it, and select it.
Thanks for any help.
Mark
Have you debugged this and made certain that
..
.
Dim i as integer
For i = 0 to mtArrNumItems(Session("activitywhennum"))
Dim mylistitem as new listitem
mylistitem = cbAvail.Items.FindByValue(mtArrRetItem(Session("activitywhennum"),i))
mylistitem.selected = true
Next
..
.
.
Function mtArrNumItems(ByVal mtArr as String) as Integer
Dim arr as Array
arr=Split(mtArr,",")
Return Ubound(arr)
End FunctionFunction mtArrRetItem(ByVal mtArr As String, ByVal index as integer) as String
Dim arr as Array
arr=Split(mtArr,",")
Return arr(index)
End Function
cbAvail.Items.FindByValue(mtArrRetItem(Session("activitywhennum"),i))
actually returns an item? If this returns null then your mylistitem object will be null and you'd get an error. In order to figure out why it doesn't find anything you'd have to tell us where this code executes and what your page load event looks like.
0 comments:
Post a Comment