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 835485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:50:03+00:00 2026-05-15T04:50:03+00:00

I have a drop down which has a method which binds data to it:

  • 0

I have a drop down which has a method which binds data to it:

dropDown.Items.Clear()
dropDown.AppendDataBoundItems = True
Select Case selType
    Case SelectionTypes.Empty
        dropDown.Items.Insert(0, New ListItem("", ""))
    Case SelectionTypes.Any
        dropDown.Items.Insert(0, New ListItem("ANY", ""))
    Case SelectionTypes.Select
        dropDown.Items.Insert(0, New ListItem("Select One", ""))
    End Select
BindDropDown(val)

The BindDropDown method simply sets the datasource, datakeyname, datavaluename, and then databinds the data.

For a reason which I cannot avoid, I MUST call this method twice sometimes. When it is called twice, All of the databound items show up two times, but the top item (the one I manually insert) is there only once.

Is ASP doing something wierd when i databind twice even though i clear the list between? Or does it have to do something with the viewstate/controlstate?

EDIT

The entire page, and this control has EnableViewState=”false”

EDIT 2

The dropdown is inside a form view. After the selected value is set I have to rebind the dropdown just in case the selected value is not there [because it is an inactive user]. After this, the formview duplicates the databound items.

  • 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-15T04:50:04+00:00Added an answer on May 15, 2026 at 4:50 am

    Here is what was happening:
    My dropdown control binds the data when the selected index is set. So it sets the DataSource to be my table of values and it calls DataBind.

    When the formview is bound, it sets the selected index which binds my dropdown HOWEVER after this happens the formview calls DataBind() on ALL of its children. And since my dropdown has AppendDataBoundItems = “True” it adds the items in the DataSource again to the dropdown.

    My solution:

    SET DataSource to be null after I call DataBind() in the SelectedIndex Property. This way when the Formview calls DataBind() it appends no items and therefore I have no more duplicates.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code which has a drop down list. And when a certain option
Here's the situation I have a webpage which has one drop down called prefer.
I have a requirement to add a standard drop-down from which you can select
I have a form in an ASP.NET MVC project which has a select drop
I have a website on with MVC, which has a dropdown in the masterpage.
I have a drop down menu which you can see here on jsfiddle .
I have a drop down menu which fills with some doc names. Now when
I have a drop-down list which is generated based on the following sql query:
I have a drop down list which is dynamically generated using ajax on page
I have a dynamic drop down box which calls another PHP page. I've got

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.