62,041
社区成员
发帖
与我相关
我的任务
分享
public void GetPanelControl()
{
DataTable dt = DataLayer.GetAllPEQUIPSource();
for (int i = 0; i < dt.Rows.Count; i++)
{
CheckBox ckbox = new CheckBox();
ckbox.AutoPostBack = false;
string str= dt.Rows[i]["PIP"].ToString();
int count = str.Length;
ckbox.Text = str.Substring(str.LastIndexOf('.')+1,2);
ckbox.ID = "ckbox" + i;
this.panList.Controls.Add(ckbox);
}
}
foreach(Control ctl in this.Controls)
{
if(ctl is Button) //服务器控件
{
}
if(ctl is System.Web.UI.HtmlControls.HtmlButton) //html控件
{
}
}
protected void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i <= 10; i++)
{
CheckBox ckbox = new CheckBox();
ckbox.Text = i.ToString();
PlaceHolder1.Controls.Add(ckbox);
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
string checkeditem = "";
foreach (Control ctl in PlaceHolder1.Controls)
{
if (ctl is CheckBox)
{
if (((CheckBox)ctl).Checked)
{
checkeditem += ((CheckBox)ctl).Text;
checkeditem += "<br/>";
}
}
}
Response.Write(checkeditem);
}