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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:22:05+00:00 2026-06-13T09:22:05+00:00

Can anyone help me with a C# loop to populate an ASP:DropDownList. I am

  • 0

Can anyone help me with a C# loop to populate an ASP:DropDownList. I am using the following code to bind the data to my dropdown. However, the first result doesn’t populate in the drop down list. There should be 3 however, there is only 2 in the dropdown list.

Any help is great.

        SqlDataReader dr;
        dr = sqlcmd.ExecuteReader();
        dropdown.DataSource = dr;

        while (dr.Read())
        {
            dropdown.DataValueField = "ID";
            dropdown.DataTextField = "Description";
            dropdown.DataBind();
        }
  • 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-06-13T09:22:06+00:00Added an answer on June 13, 2026 at 9:22 am

    Since you’re binding the data reader to the drop down, you don’t need to loop at it explicitly (the call to dr.Read() is effectively eating the first element).

    Try this:

    SqlDataReader dr = sqlcmd.ExecuteReader();
    dropdown.DataSource = dr;
    dropdown.DataValueField = "ID";
    dropdown.DataTextField = "Description";
    dropdown.DataBind();
    

    UPDATE

    To add a default item, do this after the code above:

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

Sidebar

Related Questions

Can anyone help me change this code back to a simple for loop? public
Can anyone help explain to me why the following is returning duplicate data? <?php
Can anyone help: Required: SSIS Package to loop through a folder (containing 100 files)
can anyone help me calculate the complexity of the following? I've written a strStr
Can anyone help me with this code snippet: -(void) updateData:(NSString*)value1:(NSString*)value2 { sqlite3* database; databaseName
Can anyone help me in debugging a for loop in netbeans. The issue is
Can anyone help me with this error. It works when I try the first
Can anyone offer more help on this I have the code setup on jsfiddle
Can anyone help me by telling me what is wrong with the following syntax?
can anyone help me with loop in batch for windows? i want make script

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.