我希望我的Reader结果对象获取matchinng id,它匹配q = 2个表,然后得到结果并保存它。 然后行数据绑定函数与所有网格匹配,如果匹配任何行,则选中该行的复选框
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string qry = "SELECT id FROM info INTERSECT SELECT id FROM info2;";
SqlCommand cmd = new SqlCommand(qry, con);
con.Close();
if (con.State == ConnectionState.Closed)
{
con.Open();
// string result = ((string)cmd.ExecuteScalar());
int result = ((int)cmd.ExecuteScalar());
//SqlDataReader dr = cmd.ExecuteReader();
// CheckBox chk = (CheckBox)e.Row.cells[0].FindControl("chkMyCheckBox");
CheckBox Chbox = (CheckBox)e.Row.Cells[0].FindControl("chb1");
if (e.Row.Cells[1].Text == result.ToString())
{
Chbox.Checked = true;
e.Row.Cells[1].ForeColor = System.Drawing.Color.Red;
}
else if (e.Row.Cells[2].Text == "1")
{
e.Row.Cells[1].ForeColor = System.Drawing.Color.Black;
}
else
{
e.Row.Cells[1].ForeColor = System.Drawing.Color.Green;
}
}
}