通过这个代码,我从数据库编辑表格以便在检索值:做一个单选按钮被查取决于值在数据库
OleDbCommand Comm1 = new OleDbCommand("select image1,image2,image3,image4,measurement,property_purpose,bedrooms,bathrooms,furnishing,property_price,property_price_per_mu,existing_customer from tb_property where property_id = ?", con);
Comm1.Parameters.AddWithValue("property_id", txt_prop_id.Text);
OleDbDataReader DR1 = Comm1.ExecuteReader();
if (DR1.Read())
{
txt_image1.Text = DR1.GetValue(0).ToString();
txt_image2.Text = DR1.GetValue(1).ToString();
txt_image3.Text = DR1.GetValue(2).ToString();
txt_image4.Text = DR1.GetValue(3).ToString();
combo_measure.Text = DR1.GetValue(4).ToString();
combo_purpose.Text = DR1.GetValue(5).ToString();
combo_bedrooms.Text = DR1.GetValue(6).ToString();
combo_bathrooms.Text = DR1.GetValue(7).ToString();
combo_furnishing.Text = DR1.GetValue(8).ToString();
txt_price.Text = DR1.GetValue(9).ToString();
txt_price_per_mu.Text = DR1.GetValue(10).ToString();
var val = DR1.GetValue(11).ToString();
if (val == "Yes")
{
radioButton1.Checked;
}
if (val == "No")
{
radioButton2.Checked;
}
}
与radiobuttons
如果val
在Yes
现在我有麻烦那么应该检查数据库radiobutton1
。
如果No
在数据库中,则应选择radiobutton2
。但语法是一个显示错误,任何人都可以请帮助我吗?
thanku ..sir it workrd – user3181292
两个if语句没有意义使用'else if' –
@SriramSakthivel thanx更新! –