Looping through a formview web control .. childtable?

Discussion in 'ASP .Net' started by jobs, Nov 10, 2006.

  1. jobs

    jobs Guest

    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???


    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"),
    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
    returnvalue = False
    End If
    End If

    End If

    Return returnvalue
    jobs, Nov 10, 2006
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.