我希望我的 Reader 结果对象获取匹配 q=with 2 个表的匹配 id,然后获取结果并保存它。然后行数据绑定函数与所有网格匹配,如果在任何行上匹配,则选中该行的复选框
{
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;
}
}
}