I would like to know what is the best practice between using bind tag and setting direct property to a 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 being best to separate design from code giving the liberty of changing even ID without breaking code. But it seems we can get very long bind tag sometime like this really short example:
Text='<%# ((fn_SearchReminders)Container.DataItem).dtDateActivation.Value.ToString("yyyy-MM-dd - hh:mm") %>'