Monday, October 17, 2011

Determine if VB.NET control exists

Sub disable_ActionLinks()

        Try
            Dim Item1 As DataListItem   ' for the first DataList
            'Dim Item2 As DataListItem   ' for the second DataList       

            '########################################################################
            For Each Item1 In dlst_TEST.Items

                Dim lb_edit As LinkButton = dlst_TEST.Items(Item1.ItemIndex).FindControl("edit")

                If lb_edit IsNot Nothing Then
                    lb_edit.Visible = False
                End If
                'If Page.FindControl("IDofControl") IsNot Nothing Then

                'Dim lb_remove As LinkButton = dlst_TEST.Items(Item1.ItemIndex).FindControl("remove")               
                'lb_remove.Visible = False

                'dlst_Group2 = dlst_Group1.Items(Item1.ItemIndex).FindControl("dlst_Group2")
                ''#######################################################################
                'For Each Item2 In dlst_Group2.Items
                '    Dim rbl_Group2 As RadioButtonList = dlst_Group2.Items(Item2.ItemIndex).FindControl("rbl_Group2")
                '    rbl_Group2.Enabled = False
                '    'Response.Write(rbl_Group2.ID)
                'Next

            Next

        Catch ex As Exception
            With Me
                .lblMessage.Text = "error disabling controls. " & ex.Message
                .Bad_Message()
            End With
        End Try

    End Sub

No comments:

Post a Comment