Hi

i am using .net 2.0 & a window application which is connected to sql server
there is checkbox in the application. i want to bind the checkbox with database field which is bit type 1 or 0 please tell how to ?

in my window form there is three tabPages. the first tab page is for filter in which we provide condition to filter data on diff. conditions like id party name, city etc in second tabpage there is datagrid view to show result on base of filter then we select a row from datagrid view which we want to edit then this record is transffered to third tab page in which there are textbox & combobox & checkbox like below

cnn.Open();
                SqlDataAdapter da = new SqlDataAdapter("select * from publicity where id=@id", cnn);
                da.SelectCommand.Parameters.Add("@id", SqlDbType.VarChar).Value = cobjCellValue;
                DataTable dt = new DataTable();
                da.Fill(dt);
                txtPartyName.Text = dt.Rows[0][1].ToString();
                txtAddress.Text = dt.Rows[0][2].ToString();
                txtCity.Text = dt.Rows[0][3].ToString();
                cboCountry.Text = dt.Rows[0][4].ToString();
                cboCategory.Text = dt.Rows[0][5].ToString();
                txtPhone.Text = dt.Rows[0][6].ToString();
               // chkActive.Checked=dt.Rows[0].i
              // chkActive.DataBindings.Add("Checked", dt, "Active"); 
                txtFax.Text = dt.Rows[0][7].ToString();
                txtEMail.Text = dt.Rows[0][9].ToString();
                txtWebAddress.Text = dt.Rows[0][10].ToString();
                tabctrlPublicity.SelectedTab = tabPageAddEdit;

Recommended Answers

All 2 Replies

chkActive.Checked=(bool)dt.Rows[0];

I mean
chkActive.Checked=dt.Rows[0][whateverColumnThisIs];

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.