2013年12月3日 星期二
用foreach 來找控制向
foreach (object ob in panel.Controls)
{
if (ob.GetType().FullName == "System.Web.UI.WebControls.DropDownList")
{
DropDownList ddl = (DropDownList)ob;
Utility.BindDropDownList(ddl, sys.USP_COMM060_S00(""), "STAFFNO", "STAFFNM", true);
}
}
foreach (object ob in panel.Controls)
{
if (ob.GetType().FullName == "System.Web.UI.WebControls.DropDownList")
{
i++;
DropDownList ddl = (DropDownList)ob;
TextBox txtMTDT = (TextBox)ddl.Parent.FindControl("txtMTDT" + i);
Label labelg = (Label)ddl.Parent.FindControl("Label" + i);
CheckBox checkb = (CheckBox)ddl.Parent.FindControl("a" + i);
Label labid = (Label)ddl.Parent.FindControl("labid" + i);
labid.Text = dt.Rows[i - 1]["CSTEACHER"].ToString().Trim();
ddl.SelectedValue = dt.Rows[i - 1]["CSTEACHER"].ToString().Trim();
checkb.Visible = ddl.SelectedValue != "" && ddl.SelectedValue != USER.USERID ? false : true;
labelg.Text = dt.Rows[i - 1]["CSTEACHERNM"].ToString().Trim();
labelg.Text = labelg.Text.Trim() == "" ? "請選擇" : "who: " + labelg.Text;
checkb.Checked = ddl.SelectedValue == USER.USERID ? true : false;
txtMTDT.Text = Convert.ToDateTime(dt.Rows[i - 1]["MTDT"]).ToString("yyyy-MM-dd HH:mm:ss.fff");
}
}
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言