最好用客户端控件,循环命名即可,后台生成的服务器端控件在客户端不能使用。
例子:
string strsql = "select * from [ZF]专业建设 where '" + strSD + "' = " + strsysid;
KBaseServerDAL kal = new KBaseServerDAL();
RecordSet rs = kal.GetDataSetBySQL(strsql);
if (rs != null && rs.GetCount() > 0)
{
for (int i = 0; i < rs.GetCount(); i++)
{
if (str3 == "任课教师")
{
SelectOther1(rs.GetValue(str3));
}
else if (str3 == "课程名称")
{
SelectOther2(rs.GetValue(str3));
}
else
{
htmlBody += "
" + str3 + " | " + rs.GetValue(str3) + " |
(TextBox)Panel1.FindControls("Textname").Text="应该是这样的";
Label labela;
for (int i = 0; i < 5; i++)
{
labela = new Label();
labela.Name = "temp" + i.ToString();
//labela.ID = "temp" + i.ToString();
labela.Text = "temp" + i.ToString();
this.Controls.Add(labela);
}
this.textBox1.Text = ((Label)(this.Panel1.Controls["temp0"])).Text;
protected void mytemp()
{ Label labela;
for (int i = 0; i < 5; i++)
{
labela = new Label ();
labela.ID = "temp" + i.ToString ();
labela.Text = "temp" + i.ToString ();
if(i==3){textBox1.text= labela.text;} //加上这个判断就可以了
Panel1.Controls.Add(labela);
}
}