簡體   English   中英

我想訪問for loop.so中的asp.net服務器控件的“ ids”,因此我可以單行設置所有控件的值

[英]i want to access 'ids' of asp.net server controls in for loop.so with single line i can set value to all controls

for(int i = 1; i < 5;i++)
{
    label[i].InnerText = info.books[0].title;
}

我想要這樣的東西來循環訪問5個服務器控件的ID。 LABEL1,LABEL2,.....,label5。 它是文件后面的代碼。

如果您真的想要,可以使用FindControl

for (int i = 1; i < 5; i++)
{
    Label lbl = Page.FindControl("Label" + i) as Label;
    lbl.Text = info.books[0].title;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM