我正在动态生成复选框,如果两个查询的 o/p 匹配,则最初 2 个查询 r 匹配,然后在这种情况下,特定复选框被选中并禁用......但在我的情况下与查询的匹配 o/p 对应的匹配复选框被禁用,但未被选中
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = c.readDataSet("select teacher_id, name from teacher");
DataTable dt = ds.Tables[0];
foreach (DataRow drow in dt.Rows)
{
chk = new CheckBox();
chk.ID = "chk_" + drow[0].ToString();
SqlDataReader dr = c.readData("select t.teacher_id from teacher t join coordinator c on t.teacher_id=c.teacher_id where c.branch='" + ddl_class.Text + "' and c.cyear=" + DateTime.Now.ToString("yyyy")+" and c.status=2" );
while (dr.Read())
{
if(dr.GetString(0)==drow[0].ToString())
{
chk.Checked = true;
chk.Enabled = false;
count = 1;
}
}
dr.Close();
chk.ToolTip = drow[1].ToString();
lb = new Label();
lb.Text = drow[1].ToString();
PnlCtrl.Controls.Add(chk);
PnlCtrl.Controls.Add(lb);
PnlCtrl.Controls.Add(new LiteralControl("<br/>"));
}
}