I would like to know what the best practice is to use the bind tag and set the direct property for the control in asp.net.
aspx.cs
public string Description {get; set;}
Aspx
<asp:Literal ID="txtDescription" runat="server" Text='<%# Description %>' />
aspx.cs
public string Description
{
get { return txtDescription.Text ; }
set { txtDescription.Text = value; }
}
Aspx
<asp:Literal ID="txtDescription" runat="server" />
The first of them is best to separate the design from the code, which gives the freedom to change an even identifier without breaking the code. But it looks like we can get a very long binding tag, for example, this short example:
Text='<%# ((fn_SearchReminders)Container.DataItem).dtDateActivation.Value.ToString("yyyy-MM-dd - hh:mm") %>'
source
share