ASP.Net/C# - FindControl Question
Posted on 2009-04-22
I have a repeater where in that repeater I have a label. What I am doing is appending to the ID of the label control a JobID which is unique to each row. For example:
<asp:Label ID="lblPublish_<%#Eval("BILLING_JOB_ID")%>" runat="server" ForeColor="red"></asp:Label>
Now I store the control id and the text value it will have into a generic list so I can handle state with something because of AJAX being used. When I do a findcontrol on the ID it is not working, however it was working if I just had it as "lblPublish". I looked in the source and the ctrlName I put together is exact and there in the source code for the HTML.
RepeaterItem ri = btnPublish.NamingContainer as RepeaterItem;
string ctrlName = "lblPublish_" + btnPublish.CommandArgument;
Label lbl = (Label)ri.FindControl(ctrlName);
now its coming out null. I have to append somehow to my generic list a control id or something so I know that is the control in my list row when I do looping later to write out some data. Any ideas?