Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7581743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:16:05+00:00 2026-05-30T18:16:05+00:00

The application that I am working on is a Service Desk App. I have

  • 0

The application that I am working on is a Service Desk App. I have a form there that uses a DropDownList that contains employees names coming from the Active Directory. Any employee can make a request and save it.

Problem arises when an employee leaves the company and consequently his account is deleted from the Active Directory. When some other employee searches the DB to finds a relevant Service Ticket that could be of his use, when tries to open it an error is thrown that indicates that the name does not exist in the DropDownList items.

What I need is a solution so that the functionality will remain the same (be able to delete the Active Directory entry), but no error will be thrown.

I am using as indicated by the tags, ASP.NET with VB. Solutions with C# are also welcome.

Thank you in advance for your suggestions to my problem.

UPDATE:

I am adding some code so that it can be more clear.

ASPX: (This is huge, I am putting only the DropDownList in question)

<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" 
        DataKeyNames="ITRequestId">
        <EditItemTemplate>
            <br />
            <asp:LinkButton ID="LinkButton5" runat="server" CausesValidation="True" 
                CommandName="Update" Text="Update" CssClass="InsertLink" />
            &nbsp;&nbsp;&nbsp;<asp:LinkButton ID="LinkButton6" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" CssClass="CancelLink" />

                    ........    

                    <div id="user" style="float: left;">
                        <label>User:<asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ErrorMessage="User" Display="Dynamic" ControlToValidate="DropDownList5" Text="*" ForeColor="#FF0000"></asp:RequiredFieldValidator></label><br />
                        <asp:DropDownList ID="DropDownList5" runat="server" SelectedValue='<%# Bind("ITRequestUserName") %>'>
                            <asp:ListItem Value=""></asp:ListItem>
                            <asp:ListItem Value="All">All</asp:ListItem>
                            <asp:ListItem Value="NA">N/A</asp:ListItem>
                        </asp:DropDownList>
                    </div>

                    .........
        </EditItemTemplate>

CODE BEHIND vb: (This is huge, but I am putting the pageload event where the error is thrown)

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If (Not IsPostBack) Then
        If Request.UrlReferrer IsNot Nothing Then
            ViewState("RefUrl") = Request.UrlReferrer.ToString()
        End If
    End If
    'Handles the mode of the FormView according to the request
    If Request.QueryString.Get("ITRequestId") IsNot Nothing Then
        FormView1.DefaultMode = FormViewMode.ReadOnly
        Dim tName As String = DirectCast(FormView1.Row.FindControl("DropDownList5"), DropDownList).SelectedValue
        Dim temptype As String = DirectCast(FormView1.Row.FindControl("DropDownList1"), DropDownList).SelectedItem.Text
        Dim myAD As New tActiveDirectory(LDAPpath)
        Dim lName As String = HttpContext.Current.User.Identity.Name.ToString()
        Dim sDisplayName As String = myAD.GetUserInfo(lName, "displayName")
        Dim cName As String = DirectCast(FormView1.Row.FindControl("Label5"), Label).Text
        If Not (User.IsInRole("Developers") Or User.IsInRole("Administrators") Or tName = sDisplayName Or cName = sDisplayName) Then
            If (temptype = "Access rights") Then
                Response.Redirect("../IT/ITAccessDenied.aspx")
            End If
        End If
        If Not (User.IsInRole("Developers") Or User.IsInRole("Administrators") Or cName = sDisplayName) Then
            If (temptype = "Account") Then
                Response.Redirect("../IT/ITAccessDenied.aspx")
            End If
        End If
        If Not (User.IsInRole("LocalIT")) Then
            If (temptype = "Internal IT Task") Then
                Response.Redirect("../IT/ITAccessDenied.aspx")
            End If
        End If
    Else
        FormView1.DefaultMode = FormViewMode.Insert
        Dim tempstatus As DropDownList = DirectCast(FormView1.Row.FindControl("DropDownList2"), DropDownList)
        tempstatus.SelectedIndex = 3
    End If
End Sub

The error is thrown at Line 11 of the code when declaring the tName variable. And this is happening because the UserName that is in the database and is to be bounded by the DropDownList has been deleted from the ActiveDirectory and thus it does not exist in the values of the List.

Here is the code that populates the DropDownList:

Protected Sub FormView1_ItemCreated(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.ItemCreated
    Dim d1 As DropDownList
    Dim d2 As DropDownList
    Dim myAD As New tActiveDirectory(LDAPpath)
    Dim users As New ArrayList()
    users = myAD.GetAllUsersInfo()
    d1 = DirectCast(FormView1.Row.FindControl("DropDownList5"), DropDownList)
    d2 = DirectCast(FormView1.Row.FindControl("DropDownList7"), DropDownList)
    d1.DataSource = users
    d2.DataSource = users
End Sub

Public Function GetAllUsersInfo() As ArrayList
        Dim Users As New ArrayList()
        Dim myDirectory As New DirectoryEntry(sPath)
        Dim mySearcher As New DirectorySearcher(myDirectory)
        Dim fullName As String
        mySearcher.Filter = "(&(objectCategory=person)(objectClass=user))"
        mySearcher.PropertiesToLoad.Add("sn")
        mySearcher.PropertiesToLoad.Add("displayName")
        mySearcher.Sort.PropertyName = "sn"
        mySearcher.Sort.Direction = SortDirection.Ascending
        Users.Add("")
        Users.Add("N/A")
        Users.Add("All")
        For Each result As DirectoryServices.SearchResult In mySearcher.FindAll
            fullName = result.Properties("displayName")(0).ToString
            Users.Add(fullName)
        Next
        Return Users
    End Function

Any help with this will be appreciated. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:16:06+00:00Added an answer on May 30, 2026 at 6:16 pm

    Your question does not have much detail regarding code. But it sounds like your app is trying to select a value in the DDL that is not there (anymore). Just check before selecting like this:

    Dim ddl As DropDownList
    Dim item As ListItem = ddl.Items.FindByValue("Kostopoulos")
    If item IsNot Nothing Then
      ddl.SelectedIndex = ddl.Items.IndexOf(item)
    Else
      ddl.Items.Add(New ListItem("Not available"))
      ddl.Enabled = False
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an application that uses Sudzc to interface with a SOAP web-service.
I am working on a Silverlight application that uses WCF. I need to have
I'm working with a legacy WebLogic application that contains a web-service application and a
I have a web application that uses ajax enabled wcf service Service.scv .... I
I have a Java application that is working as a service. After several days
So i have a service for an application that i am working on. This
I am working on an application that uses a private web service. We currently
I have implemented a windows xp service application that starts a couple of working
I am working on a Java Web Application that exposes a web service. This
Working on a service application in Delphi 5 that is intended to run on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.