DropDownList.SelectedItem.Text returning Null
-
I am populating a drop down list from AD, which is working fine (The drop downlist is populated when I browse to the site.) The problem I am having is that when I later go to use that data with dropdownlist.SelectedItem.Text, nothing is returned. Any suggestions?
Dim Groups1 As New DirectorySearcher Dim GroupSearchRoot1 As New DirectoryEntry("LDAP://OU=SomeOU,OU=SomeOU,OU=SomeOU,DC=SomeDomain,DC=SomeTopLevelDomain") With Groups1 .SearchRoot = GroupSearchRoot .Filter = "(&(ObjectClass=Group)(CN=SomeGroup))" End With Dim Members1 As Object = Groups1.FindOne.GetDirectoryEntry.Invoke("Members", Nothing) For Each Member As Object In CType(Members1, IEnumerable) Dim CurrentMember1 As New DirectoryEntry(Member) dropdownlist.Items.Add(CurrentMember1.Name.Remove(0, 3)) Some code to sort the dropdownlist alphabetically...
-
I am populating a drop down list from AD, which is working fine (The drop downlist is populated when I browse to the site.) The problem I am having is that when I later go to use that data with dropdownlist.SelectedItem.Text, nothing is returned. Any suggestions?
Dim Groups1 As New DirectorySearcher Dim GroupSearchRoot1 As New DirectoryEntry("LDAP://OU=SomeOU,OU=SomeOU,OU=SomeOU,DC=SomeDomain,DC=SomeTopLevelDomain") With Groups1 .SearchRoot = GroupSearchRoot .Filter = "(&(ObjectClass=Group)(CN=SomeGroup))" End With Dim Members1 As Object = Groups1.FindOne.GetDirectoryEntry.Invoke("Members", Nothing) For Each Member As Object In CType(Members1, IEnumerable) Dim CurrentMember1 As New DirectoryEntry(Member) dropdownlist.Items.Add(CurrentMember1.Name.Remove(0, 3)) Some code to sort the dropdownlist alphabetically...
This looks messy and complicated. I also don't see any code to stop it running every postback, or any indication where it runs. If you run this code in page load, it resets the data source, and thus will cause the selection to be lost.
Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
-
This looks messy and complicated. I also don't see any code to stop it running every postback, or any indication where it runs. If you run this code in page load, it resets the data source, and thus will cause the selection to be lost.
Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
The site is simply a one page form with a submit button, basically a web form for employees to use for new user requests. On submit a specifically crafted email is sent to our ticketing system creating a ticket for the various IT groups involved in New User setups. The ticketing system sends an email to an "Authorized Manager" asking for approval for the request. The drop down list is a list of Authorized Managers. Currently the site is in prod, with a hard coded list of Authorized Managers, I am trying to improve it by using AD Security groups so that I don't have to manually maintain the list. Should I ditch the above code and try something else, or is there some way that I can salvage it? I am just a script monkey Sys Admin trying his hand at "actual" prgramming to improve process.