The Feb. Issue of the UT Magazine has a tip about how to iterate through all the controls on the ASP.NET page. Here is the link to the Feb. Issue. Click on the picture of the magazine and then click on "Cathi Gero's .NET Tips". The tip is the one on the lower left:
http://www.levelextreme.com/Magazine/>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
-----------------------------------------
Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.comwww.prenia.comWeblog: blogs.prenia.com/cathi