Hello,
I have a checkbox in a databindingNavigator. How can i get its state?
In my database i have a field call checked(nvarchar) that gets value 1 if checkbox is checked and 0 if unchecked.
I get that value in a textfield, so i have the following:
Textbox temp_check=new Textbox();
temp_check.Databindings.Add("Text",bindSource,"CHECKED");
if (temp_check.Text=="1")
check1.CheckState=System.Windows.Forms.CheckState.Checked;
else
check1.CheckState=System.Windows.Forms.CheckState.Unchecked;
My problem is that with the above code i set checkbox to checked/unchecked for all records not only the specific. How can i connect it to my bindingNavigator?
Thank you in advance.
Loading
DealyPosted Sep 18, 2009, 6:34 AM
Thank you.
DealyPosted Sep 14, 2009, 2:13 AM
{
string connectionString = @"Server=LOC; Initial Catalog=Northwind; Integrated Security=True";
using (SqlConnection conn = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand("SELECT_ORDERS", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@CustomerID", CustID));
conn.Open();
//Fill The DataTable From Command
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
//Set It To Binding Navigator
BindingSource itmBindSource = new BindingSource();
itmBindSource.DataSource = dt;
itmBindNavigator.BindingSource = itmBindSource;
itmBindNavigator.Dock = DockStyle.Bottom;
TextBox temp_checked = new TextBox();
temp_checked.DataBindings.Add("Text", itmBindSource, "ShipPostalCode");
if (temp_checked.Text != null)
checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
else
checkBox1.CheckState = System.Windows.Forms.CheckState.Unchecked;
custID_txt.DataBindings.Add("Text", itmBindSource, "CustomerID");
shipRegion_combo.DataBindings.Add("SelectedValue", itmBindSource, "ShipRegion");
freight_txt.DataBindings.Add("Text", itmBindSource, "Freight");
}
}
Thank you :)
Roei BarPosted Sep 13, 2009, 3:54 PM
DealyPosted Sep 13, 2009, 2:59 PM
Thanks again
Roei BarPosted Sep 13, 2009, 2:38 PM