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

  • Home
  • SEARCH
  • 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 6708933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:49:11+00:00 2026-05-26T07:49:11+00:00

I have other trouble and I cannot solve it. In ASP.NET I have DropDownList

  • 0

I have other trouble and I cannot solve it.

In ASP.NET I have DropDownList object which takes data from a Generic List. In ASP.NET page

<tr><td>Choose category</td>
<td><asp:DropDownList id="list_categories" runat="server"></asp:DropDownList></td>
<td>
<asp:RequiredFieldValidator ControlToValidate="list_categories" runat="server" Display="Static" ErrorMessage="Select category" ID="verify_category" ValidationGroup="add_link_group">
</asp:RequiredFieldValidator></td></tr>

and the behind code :

private void generate_select( DropDownList select ) {

         BusinessLayerArcht layer = LoadDataFromBL();

         foreach ( CategoriesCtrlDto cto in layer.Categories ) {          
            select.Items.Add( cto.Name );
         }
      }

and the Page_Load

generate_select( list_categories );

I tried with Clear() but when I added a new link to a selected category , it will be inserted at first category
If I don’t call .Clear() function then the inseration it’s ok but after page refreshing, the list contains duplicate categories

Initial I had
GMail
YMail
AOL

after inserting a new link or other event which refresh page, the list will shows as :
GMail
YMAil
AOL
GMail
YMAil
AOL

If I refresh four times the page then the list has
GMail
YMAil
AOL
GMail
YMAil
AOL
GMail
YMAil
AOL
GMail
YMAil
AOL

Repeats four times, so it duplciates at each page postback or refresh.
I tried also to clear cache if (Page.isPostBack)

  • 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-26T07:49:12+00:00Added an answer on May 26, 2026 at 7:49 am

    You have to do

    if(!Page.IsPostBack)
    generate_select(list_categories);
    

    !Page.IsPostBack ==> if is NOT postback. If you execute the code every postback, it will insert duplicate records

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

Sidebar

Related Questions

I'm having some trouble figuring out to call methods that I have in other
I have seen the other posts but I am still having trouble. Below is
I have been using SmartGWT but have run into trouble mixing SmartGWT with other
I have other pages within my app preferences which are stored as separate files
I have other-window.xaml file and trying to open this from window.xaml on button click.
I have some strange behavior occurring in an ASP.NET application that I am trying
I have built a music player which loads songs from a database in a
I have some trouble reading from an ini file using boost program options. The
I'm having trouble with the webparts variables... I came from standard ASP language, so,
I have trouble sorting two related but separate lists of tuple lists. One list

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.