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

The Archive Base Latest Questions

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

I have this dropdownlist populated and everything. The only problem is that whenever I

  • 0

I have this dropdownlist populated and everything. The only problem is that whenever I add a new item in the database through my website, the dropdownlist doesn’t update for some reason.

private CurrentUser _cu = new CurrentUser();//just to check if use is an admin or not.

    protected void Page_Load(object sender, EventArgs e)
    {           
        _cu = (CurrentUser)Session[Common.SessVariables.CurUser];
        if (!_cu.CanReport) { Response.Redirect("~/default.aspx"); }

        CurrentUser cu = (CurrentUser)Session[Common.SessVariables.CurUser];
        if (!IsPostBack)
        {
            foreach (PrefixAdd loc in cu.Prefix)//Prefix is a Property
            {
                ListItem x = new ListItem(loc.Prefix);
                PrefixID.Items.Add(x);
            }
        }

    }

@Wayne I’m using a store procedure to just insert a Prefix like Pre,yes,sey, etc. Then the list is populated with prefixes.

StringBuilder sbSQL = new StringBuilder(255);
sbSQL.Append(string.Format("exec insPrefix @Prefix=N'{0}';", PrefixBox.Text.Trim()));
string msg = string.Empty;
msg = (_oDAW.ExecuteNonQuery(sbSQL.ToString())) ? string.Format(Common.GetAppSetting(Common.ConfigKeys.User_Submit_Success), 
PrefixBox.Text.Trim()) : Common.GetAppSetting(Common.ConfigKeys.SubmitFail); //this is a somewhat custom method for CS and databinding.

@ Yuriy Rozhovetskiy Yea I add new items to this page with the dropdownlist.

  • 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-26T10:30:50+00:00Added an answer on May 26, 2026 at 10:30 am

    Whenever you add an item to your database, you have to rebind your drop down list.

    yourDropDown.DataSource = //...
    yourDropDown.DataBind();
    

    That is, DropDownLists (and other controls) have no way of knowing that their data has changed behind the scenes, they can’t automatically detect it. You have to tell the controls to rebind their data manually.

    Good job on the Page_Load(...){ if !(IsPostback) part.

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

Sidebar

Related Questions

I have a dropdownlist that is being populated from a database. That is working
I have the following code that sets a cookie: string locale = ((DropDownList)this.LoginUser.FindControl(locale)).SelectedValue; HttpCookie
I have a DropDownList on an ASP.NET page that gets populated by a SQL
I have a DropDownList populated with a SelectList generated from (an anonymous type) that
I have a DropDownList that is populated from a datasource. After it is bound,
I have a DropDownList being populated with items coming through DataBinding from a WCF
I have a DropDownList inside an UpdatePanel that is populated on postback from a
If you have a form and the only parts in this form that you
I have a DropDownList control that is populated via server side. I use a
I have a this aspx-code: (sample) <asp:DropDownList runat=server ID=ddList1></asp:DropDownList> With this codebehind: List<System.Web.UI.WebControls.ListItem> colors

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.