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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:50:58+00:00 2026-05-24T21:50:58+00:00

Currently I have a drop downlist as follows: <asp:DropDownList ID=DropDownList1 runat=server AutoPostBack=True OnSelectedIndexChanged=SelectionHasChanged DataSourceID=SqlDataSource1

  • 0

Currently I have a drop downlist as follows:

<asp:DropDownList  ID="DropDownList1" runat="server"  AutoPostBack="True" 

    OnSelectedIndexChanged="SelectionHasChanged"
                DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="ID" 
                 Width="214px">
            /asp:DropDownList>

            asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:MyDBConnectionString1 %>" 
                SelectCommand="SELECT [ID], Name], [Name] FROM [Names]">
            /asp:SqlDataSource>

There are two things I’m trying to get the list to do when selection is either updated or deleted:
1)Remove deleted contents from DropDownList
2)The first entry in the database is found in the field when the page is loaded, I would like it to either be blank or say “Select”

Currently I need to refress the page to refresh the dropdownlist of deleted items.

I have tried adding DropDownList1.DataBind(); in various methods (page_load, update, delete) and DropDownList1.DataSource = SqlDataSource1; (but I get a message to delete an object of (SqlDataSource1?)

I have added a tag/controll called EnableViewState="false", this refreshs the dropdownlist when I select another item, but when I delete an item I need the list to refresh right away.

  • 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-24T21:51:01+00:00Added an answer on May 24, 2026 at 9:51 pm

    1.In order to delete an item from your dropdown list, what you do is to loop through the ListItem of dropdown list compare the value field (DataValueField) of ListItem item with the selection that has changed or deleted, remove it from dropdown list if it matches. e.g.:

    private void removeItem(string ID)
        {
            for (int i = 0; i < dropdownList.Items.Count; i++)
                if (dropdownList.Items[i].Value == ID)
                {
                    dropdownList.Items.RemoveAt(i);
                    break;
                }
        }
    

    2.Just after binding your dropdownlist, in code behind, add a new ListItem at Index 0, it will solve your problem of displaying “Select” or Blank as a top most selection:

    dropdownList.DataBind();
    dropdownList.Items.Insert(0, new ListItem("Select"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a drag and drop system for images where you drag a
Currently, I have two drop down lists that are populated with users' first and
So the problem I am currently having is that I have A drop down
i currently have an empty drop down list that I would like to fill
I currently have a dropdownlist which is populated via an SQLDataSource from the Module
I currently have no validation for my drop down list, but nevertheless, I get
I have a dropdownlist that I already have manually databinding. I currently get the
I'm working on my first true WPF MVVM pattern application. Currently I have a
Currently have password protection on my main and sub directories, however I'd like to
I currently have 4 textboxes which will be used to store an ip address.

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.