To bind current date to a label placed inside datalist

Posted by Amritha444 under C# on 12/3/2010 | Points: 10 | Views : 4329 | Status : [Member] | Replies : 1
I want to bind current date to a label placed inside a datalist. how to bind it? my code is
<asp:Label ID="lblDate" runat="server" Text='<%# Bind("DateTime.now()") %>'></asp:Label>. and error coming


Thanks in advance




Responses

Posted by: Madhuk on: 12/3/2010 [Member] Starter | Points: 25

Up
0
Down
In your datalist ItemDataBound event find label control and assign the date.

if (e.Item.ItemType == ListItemType.Item)

{
Label lblDate = e.Item.FindControl("lblDate") as Label;
lblDate.Text=DateTime.Now.ToString();
}


Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response