'String' cannot be converted to 'System.Web.UI.WebControls.CheckBox'.

hello,

am trying to loop through checkboxes, but getting an error, in the red line below and also with this

Dim b As CheckBox = ’ DirectCast(a, CheckBox)

please help

thanks

M

Compiler Error Message: BC30311: Value of type ‘String’ cannot be converted to ‘System.Web.UI.WebControls.CheckBox’.

Source Error:

Line 323: For i = 1 To incArray.GetUpperBound(0)
Line 324: Dim a As String = “chkInc” + i.ToString()
Line 325: Dim b As CheckBox = CType(a, CheckBox)
Line 326: b.Checked = True
Line 327: Next i

You’re trying to convert a String into a CheckBox, which can’t be done. What are you trying to achieve?

Cheers,
D.

thanks

i got the answer, i had to find the control

Dim b As CheckBox = CType(Page.FindControl(a), CheckBox)