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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:17:40+00:00 2026-05-24T19:17:40+00:00

I have a search.aspx page that has this: <asp:DropDownList id=ddlPopulation runat=server DataTextField=population DataValueField=pid> </asp:DropDownList>

  • 0

I have a search.aspx page that has this:

  <asp:DropDownList id="ddlPopulation" runat="server" DataTextField="population" DataValueField="pid">
                </asp:DropDownList>

I then have a data bind on page_load:

 StringBuilder sql = new StringBuilder();

    // Define sql
    sql.Append("SELECT pid, population ");
    sql.Append("FROM populations ");
    sql.Append("ORDER BY pid ASC ");

   IDataReader reader = SqlHelper.GetDataReader(sql.ToString());

    ddlPopulation.DataSource = reader;
    ddlPopulation.DataBind();

How do I:

  1. Add a default value/text pair to the list not in the database, like All populations?
  2. How do I get to do a string replace on the population data field before its shown on screen?
  • 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-24T19:17:41+00:00Added an answer on May 24, 2026 at 7:17 pm

    Add your list items to the drop down list.

    <asp:DropDownList id="ddlPopulation" runat="server" DataTextField="population" DataValueField="pid" AppendDataBoundItems="True">
        <asp:ListItem>Default</asp:ListItem>
    </asp:DropDownList>
    

    AppendDataBoundItems will force the data items to be appended to the list that is already there. So your default item will stay.

    As for doing text replacements, you can either do them in the SQL, or use DataSets/DataViews instead of straight SQL, or bind it to a list of your own objects where you can do whatever you want to do, or create a method on ItemDataBound event of the dropdown list, where you should have access to edit the information before it gets bound.

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

Sidebar

Related Questions

I have a standard button in my default.aspx page. <asp:Button ID=Search_Button runat=server Text=Search onclick=Search_Button_Click
I have an ASP.NET page that contains two div's. Both have search fields and
Let's say I have an ASP.NET web application. I create an aspx page that
I have a page in my site that has allows users to search for
I have an aspx page that has a control which serves as a summary
Lets say I have an absolute url /testserver/tools/search.aspx that I store in a variable
I have a search page that if there is results in the list it
I have a search functionality on my site that is accessible from every page.
Background: I have a website that has been built with ASP.NET 2.0 and is
I have an odd problem. I have a page called search.aspx. When the search

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.