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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:11:19+00:00 2026-05-24T16:11:19+00:00

I am binding a drop down from the database in the follwing way —

  • 0

I am binding a drop down from the database in the follwing way

-- Select an item --
Bicycles
Matresses
Games

And I am selecting the first item as default.. but if the client is an existing client and have saved this before so the table will say that they chose for example “Matresses”, the problem I am having is binding it and diplaying “Matresses” as selected when they client comes back to this page.. when i do

  ddlmyItems.SelectedIndex = ddlmyItems.Items.IndexOf
   (ddlmyItems.Items.FindByText("Matresses"));

It is choosing the correct index, but the drop down looks like this

-- Select an item --
Bicycles
-- Select an item --  //this is supposed to be Matresses
Games

I also tried changing the text back to its original name but it would not work

 ddlmyItems.SelectedItem.Text = "Matresses";

Any idea why it is not picking up the correct “Text” on the third item?, or how can i do this?

Thank you

==========================================================

  private void BindShippingDropDown(TList<StoreItems> storeItemsList, string countryCode)
{
    ddlmyItems.Items.Clear();

    ListItem liDefault = new ListItem("Select an Item", "0");

    ddlmyItems.Items.Add(liDefault);

    DataSet ds = storeItemsList.ToDataSet(false);
    DataView dv = new DataView(ds.Tables[0]);

    dv.RowFilter = "DestinationCountryCode = '" + countryCode + "' or DestinationCountryCode is null";

    if (dv.ToTable().Rows.Count > 0)
    {
        foreach (DataRow dr in dv.ToTable().Rows)
        {
            string description = dr["Description"].ToString();

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("&reg;");
            description = regex.Replace(description, "®");
            ListItem li = new ListItem(description, dr["ItemID"].ToString());
            ddlmyItem.Items.Add(li);
        }


         ddlmyItems.SelectedIndex = 0;
    }
}
  • 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-24T16:11:20+00:00Added an answer on May 24, 2026 at 4:11 pm

    If I had to take a stab at this, I think your duplicate “Select an Item” is being caused by having AppendDataBoundItems="true"

    What I’d probably do is hook into the dropdown’s OnDataBound() event, and insert the “Select an item” text at index 0.

    Then, if you want to pre-select the “Mattresses” one, maybe something like this?

    var item = dropDownList.Items.FindByText(yourValue);
    if(item != null)
    {
        dropDownList.ClearSelection();
        item.Selected = true;
    }
    

    There could be other stuff going on here (update panels, etc.) which could throw off my suggestion. If that doesn’t work; post your code for the DropDown, as well as any code that deals with the databinding and selection logic.

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

Sidebar

Related Questions

I want to select Algeria as default selected value in drop down list.I am
I am trying to fill my view model with some drop down options from
Please help I am getting the following error when I am binding the drop
I'm creating a drop down via <%= Html.DropDownList(data.Language, Model.LanguageOptions) %> and want to read
I have a drop down list, and I added some items in it as
hi m trying fill the combo box from cities database but i wan the
I have a drop down list that is being used in an EditItemTemplate of
In my application I'd like to have a drop-down box to choose a table
in the aspx page i am getting this error while binding dropdown list Unable
I am binding the dropdown with db entity. ddlCustomer.DataSource = Customer.GetAll(); ddlCustomer.DataTextField = CustomerName;

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.