How can I access the controls I add to the ItemTemplate from the code
behind file? For example, I added a label named LabelMN to the
ItemTemplate and I want to set its value to a variable in the codebehind.
Design view:
Code view:
string MobileNumber = formview1.Row.FindControl(LabelMN).ToString();
Error:
Error 1 The name 'LabelMN' does not exist in the current context
After that error I tried the following:
string MobileNumber = formview1.FindControl("LabelMN").ToString();
System.Web.UI.WebControls.Label
No error, but not the actual value of the label.
Any ideas?
Replies
Know the answer? Post it — somebody with the same question will find it here.