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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:23:25+00:00 2026-05-22T15:23:25+00:00

Suppose I have an SQL table entitled Facility which looks like this: || FacilityID

  • 0

Suppose I have an SQL table entitled “Facility” which looks like this:

|| FacilityID ||          Name        ||
      0             Lecture Theatre
      1             Seminar Room
      2             Computer Lab
      3             Electronics Lab
     ...                ...

and continues as such for 30-odd different room facilities. I’m trying to Databind these to a CheckBoxList in ASP.NET (C#) which looks like this:

<asp:CheckBoxList ID="FacilityCheckList" AutoPostBack="true" runat="server">
    </asp:CheckBoxList>

The code I’m using to achieve this in C# looks like this:

String strSQL;
strSQL = "SELECT * FROM Facility";
SqlCommand cmd3 = new SqlCommand(strSQL, DBConnection);
DBConnection.Open();
SqlDataReader FacilityData;
FacilityData = cmd3.ExecuteReader();
FacilityData.Read();
FacilityCheckList.DataSource = FacilityData;
FacilityCheckList.DataValueField = "Name";
FacilityCheckList.DataBind();
DBConnection.Close();

Now this works absolutely fine, apart from one thing: it doesn’t display a CheckBox for the first item in the list, Lecture Theatre. Every other facility in the list shows up with a CheckBox just fine, but not Lecture Theatre – and I have no idea why!

It’s not a problem on the SQL side cos when I run the query on its own, it returns the full list. And I don’t think it’s specific to CheckBoxList, because when I tried binding to a DropDownList instead, I got the same problem. I’m pretty much stumped as to why it is doing this, so any insight would be much appreciated!

Cheers

  • 1 1 Answer
  • 1 View
  • 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-22T15:23:25+00:00Added an answer on May 22, 2026 at 3:23 pm

    Remove the line:

    FacilityData.Read();
    

    This is causing the reader to move forward one notch making you lose the first item

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

Sidebar

Related Questions

Suppose I have a table like this ID Name 1 RJ 2 Hello 3
Suppose I have wrote script Table_ABC.sql which creates table ABC. I have created many
Suppose we have this person table id name gender 1 John male 2 Kurt
Suppose I have a myTest.sql scripts, which contains thousands of create table blahblah statements.
Suppose I have this table [Table1] Name Mark ------- ------ ABC 10 DEF 10
Suppose I have a string 'nvarchar(50)', which is for example the T-SQL string segment
Suppose I have a SQL table of Awards, with fields for Date and Amount.
Suppose I have an SQL Server 2005 table, TableX, with 2 indexes on it:
Suppose you have a table in SQL: Prices ------ 13.99 14.00 52.00 52.00 52.00
Suppose I have a PL/SQL function that selects one value from a table. If

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.