Mike,
Try this:
For i = 1 to 6
strTextBoxName = "txtBox" & CStr(i)
txtBox = CType(FindControl(strTextBoxName),TextBox)
If txtBox.Text >? "" Then
Some Code Here
End If
End For
HTH
Rex
>Hi I have a web form that contains numerous text boxes and dropdown boxes that have repetitive names such as:
>Drop1,drop2,drop3,etc
>text1,text2,text3,etc.
>
>I am trying to reference said controls in a loop rather than 6 seperate procedures for example:
>
>dim Cl as dropdownlist
>For i = 1 to 6
> Cl.ID = "Drop" & i
> If CL.SelectedIndex > 0 Then
> If Text1.Text <> "" Then
> Some Code Here
> End If
> If Text2.Text <> "" Then
> Some Code Here
> End If
> End If
>Next
>This gives me the error:
>Cast from type 'DropDownList' to type 'String' is not valid.
>
>Is there a way to reference controls like this? If so, How?
>
>Thanks in advance