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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:52:04+00:00 2026-06-08T09:52:04+00:00

I am currently pulling data from one of my SQL Databases into my application.

  • 0

I am currently pulling data from one of my SQL Databases into my application. I can get it working for my text boxes and other items, however, I can not seem to get it to work for a checkbox. Here is the code I am using:

DataTable dt = new DataTable("dt");
using (SqlConnection sqlConn = new SqlConnection(@"Connection Stuff;"))
{
    using (SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Box WHERE id = " + txtID.Text, sqlConn))
    {
        da.Fill(dt);
    }
}
Title.DataBindings.Add("text", dt, "title");
Picture.DataBindings.Add("text", dt, "image");
Side.DataBindings.Add("text", dt, "side");
Content.DataBindings.Add("text", dt, "content");
Check.DataBindings.Add(I dont know what to do here);

The data that is stored in the database when the checkbox is checked vs. unchecked is 0 and 1 respectivly. How would I set it to checked when the application loads if the value in the database is 1 and unchecked when it is 0?

I have tried the following:

Store the 0 or 1 in a textbox and use the following if statement:

Check.DataBindings.Add("text", dt, "check");
if (txtCheckValue.Text == 1)
{
    Check.Checked = true;
}

This way works but I was wondering if there is a more efficient way to do this. Hopefuly following the same Thing.DataBindings.Add() format, reason being that I do not want my application to have lots of hidden text boxes.

  • 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-08T09:52:06+00:00Added an answer on June 8, 2026 at 9:52 am

    Try

    Check.DataBindings.Add("Checked", dt, "check");
    

    The first parameter is the property of the control, so instead of “Text”, you want “Checked”.

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

Sidebar

Related Questions

I have a cakePHP application that is pulling data from two different databases, which
I have an sql query pulling a few results from different tables, one of
I'm pulling some internationalized text from a MS SQL Server 2005 database. As per
I am pulling data from my database and trying to encode into JSON data
I currently am pulling menu data out of our database using the PDO fetchAll()
I am currently pulling an XML feed into a webapp through ajax. Obviously i
I'm currently pulling emails from an exchange inbox like so... var exchangeService = new
Im pulling a text file - it will be input by user currently its
I have an odd one - I am porting some data from one CMS
I am pulling in weather data from a Yahoo weather RSS feed for both

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.