Looping through a formview web control .. childtable?

J

jobs

I have a many many pages with many formviews with many textboxes in
them. The matrix of types of validation I need to do is a giant mess so
please don't judge the code you are about to see - I don't want to use
the new and native validatongroups .. well at least I want to know what
I'm trying is not possible.

I'm trying to loop through the controls of formview and I think I'm
close, but Im missing something.


the below for loop erroneously only has one count.. which is ofcourse
not what I expected with over 50 textboxes in the formview while in
insert mode. I've tried to code the function expecting type formview
but that did not work either.

In my test I pass routeformview to the function Validdata

in debug

what = ctl00_ContentPlaceHolder1_RouteFormView_ctl00
what2 = System.Web.UI.WebControls.ChildTable
what3 = has a value
what4 = is empty as expected.


Am I missing something???


Thanks.

....
====
Function ValidData(ByVal whichformview As Control) As Boolean
Dim returnvalue As Boolean = True
Dim what,what2 As String
For Each c As Control In whichformview.Controls
what = c.ClientID
what2 = c.GetType().ToString
what3 = CType(RouteFormView.FindControl("iRouteDescr"), TextBox).Text
what4 = CType(RouteFormView.FindControl("iRouteCode_req"),
TextBox).Text
If c.GetType().ToString = "System.Web.UI.WebControls.TextBox" Then
If c.ClientID.Contains("_date") Then
End If
If c.ClientID.Contains("_num") Then
End If
If c.ClientID.Contains("_req") Then
If CType(c, TextBox).Text = Nothing Then
StatusLabel.Text = +c.ID + "is Required" + vbCrLf
c.Focus()
returnvalue = False
End If
End If

End If

Next
Return returnvalue
====
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top