Can I use an array in findcontrol?

前端 未结 1 1871
鱼传尺愫
鱼传尺愫 2021-01-24 11:09

Hello I have a DataList that has four lables and they all end with a number 1-4. In my code behind I have a for loop and an array that I want to set the labels of

相关标签:
1条回答
  • 2021-01-24 11:32

    You can use this code - based on string.Format("....{0}",arguments)

    var control = (Label)item.FindControl(string.Format("lbl{0}",y));
    

    I suggest you to use DataList.ItemDataBound

    Link : http://msdn.microsoft.com/fr-fr/library/system.web.ui.webcontrols.datalist.itemdatabound.aspx

    0 讨论(0)
提交回复
热议问题