Saturday, January 16, 2010

ASP.NET how to refer dynamic controls?

i have dynamically created a few controls in a place holder called PlaceHolder_Item.





when process, i need to retrieve the data in those controls, how to read back those controls?





i did set ID property for each controls but it doens't work out,





here are my codes:





Dim txtItem As TextBox = New TextBox


txtItem.ID = ';txtItem'; %26amp; i


txtItem.Text = item


PlaceHolder_Item.Controls.Add(txtItem)





when retrieve :


Dim txtItem As TextBox = New TextBox


txtItem = PlaceHolder_Item.FindControl(';txtItem'; %26amp; i)








pls help thank you.ASP.NET how to refer dynamic controls?
You should pay attention to PostBacks. Are you adding the controls again? This state management can be a pain...





Try referencing the control simply through its ID instead of using the FindControl() method of the PlaceHolder.





Hope this helps.ASP.NET how to refer dynamic controls?
smutty is right he knows alot about those electrical boxes

No comments:

Post a Comment