Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dim ass As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
Dim page As Type = ass.GetType("pagename")
For Each info As FieldInfo In page.GetFields((BindingFlags.[Public] Or BindingFlags.NonPublic) Or BindingFlags.Instance Or BindingFlags.DeclaredOnly)
If info.FieldType = GetType(System.Web.UI.WebControls.DropDownList) Then
'Dim id As String = info.Name
Dim ddl As DropDownList = DirectCast(info.Name, DropDownList)
error is value of type string cannot convert into System.Web.UI.WebControls.DropDownList
If info.Name <> "_ddlAppNo" Then
If cGlobal.IsValidValue(enmCheck.CDDL, Me, CType(info.Name, System.Web.UI.WebControls.DropDownList), "Select District") = False Then Exit Sub
Console.WriteLine(info.Name.Split("_")(1))
End If

End If
Next


and if any have code for find the id of all dropdownlist within page then plz help me
thanx
Posted
Comments
George Jonsson 10-Jul-14 3:27am    
And how would a string be converted into a DropDownList?
Maybe you mean to add items to the list?
chauhanvatsal 10-Jul-14 3:33am    
no i am not want to add to the list
i get the string which is my controllId and using that i want to check it's property like it's selected index or value etc....

You need to find the control with the name info.Name
There is a Control.FindControl[^] method.

So in your case it would be something like (warning - untested)
VB
Dim ddl As DropDownList = DirectCast(FindControl(info.Name), DropDownList)
 
Share this answer
 
findout another way to find all control id from page


VB
Public Sub FindAllTextBox(ctrl As Control)
        If ctrl IsNot Nothing Then
            For Each c As Control In ctrl.Controls
                If TypeOf c Is DropDownList Then
                   
                  DO what ever u want
                End If
                FindAllTextBox(c)
            Next
        End If
    End Sub




call it

Dim ctrl As Control = Me
FindAllTextBox(ctrl)

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900