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
  • 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-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 string 'nvarchar(50)', which is for example the T-SQL string segment
Suppose we have this table.. CREATE TABLE `appointments` ( `idappointments` int(11) NOT NULL AUTO_INCREMENT,
I have a column in Datablase Table, Suppose its Observation which contains three types
Suppose I have a stringbuilder in C# that does this: StringBuilder sb = new
Suppose we have a table A: itemid mark 1 5 2 3 and table
Suppose I have a table called Companies that has a DepartmentID column. There's also
Suppose I have a table a with one column b and three rows(1,2,3), I
Suppose you have a table: CREATE TABLE Customer ( batch_id NUMBER, customer_name VARCHAR2(20), customer_address
Suppose i have the following 2 SQL tables: Foo Column DataType --------------------------- Title NVARCHAR(20)
Suppose i have two tables declare @emp table ( EmpID int, EmpName varchar(10) )

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.