I have a page, which has a public property of type myCustomWebProfile.
In code behind I have a textbox, and I am trying to bind the text box, to a property of my web profile described above.
No matter which variations of the binding syntax I use - the textbox is never populated when it's rendered.
Any help will be greatly appreciated.
Here is the C# code-behind class:
public partial class Profile : selfSvcPage
{
public WebProfile pgProfile { get; set; }
protected void Page_Init(object sender, EventArgs e)
{
pgProfile = WebProfile.Current;
}
protected void Page_Load(object sender, EventArgs e)
{
object o = WebProfile.Current.FirstName;
//Successfully populates with a string
object b = DataBinder.Eval(pgProfile, "FirstName");
//Successfully populates with a string
}
}
Here is the code markup:
<telerik:RadTextBox ID="FirstName" Text='<%# Eval("pgProfile.FirstName") %>' SkinID="formText" CssClass="formField" runat="server"/>
Try this:
<telerik:RadTextBox ID="FirstName" Text='<%# pgProfile.FirstName %>' SkinID="formText" CssClass="formField" runat="server"/>
And this:
protected void Page_PreRenderComplete(object sender, EventArgs e)
{
DataBind();
}
In your situation you might want to bind at an earlier stage. Refer to this for details:
Why will <%= %> expressions as property values on a server-controls lead to a compile errors?
The important part: 'As the last thing i noticed... When i try with <%# %> + Control.DataBind(), then i get what i would expect. '