标签没有填充文字,我不知道为什么。我需要增加一年的lbl0到lbl6。
int year= Convert.ToInt32(hdnYear.Value);
List<Label> lbl = new List<Label>();
for (int i = 0; i < 6; i++)
{
Label lbls = new Label();
lbl.Add(lbls);
int yearValue = (FY + i);
string lblID = "lbl" + i;
lbl[i].ID = lblID;
lbl[i].Text = yearValue.ToString();
}
答案 0 :(得分:0)
你想做这样的事情:
List<Label> labels = new List<Label>();
for(int i = 0; i < 6; i++)
{
Label newLabel = new Label();
//set Properties of newLabel like ID, Content etc
labels.Add(newLabel);
}
fyi:TextBlock具有Text属性,Label具有Content属性