ASP.Net/C# - FindControl with Guid always one control in placeholder?
Posted on 2010-09-09
I am trying to figure out the simplest and cleanest way to handle this. I have some code where I swap out the user control such as a textbox, dropdownlist etc. I was naming the control the same ID name but that was causing errors. I now have the same name and then appending a GUID to the end of it to make sure I stay unique on the control name. How do I now do my findcontrol on it? I was hoping I don't have to loop through all the controls or use Session but I may be heading down this road. I don't want to use session at all for sure. Is there a way to use FindControl and a partial string? I know the start of it:
ID = "thenValue_" + guid,
Also I always only have 1 control in this placeholder at a time and if that can be used and checking to see if a control exists first that would also be perfect.