I am creating a visual web part to display the calendar events in the form of an events list with custom css. The web part will be on the home page of my site. Here is what I have right now and it is bound to a label control within an item template of a repeater:

  <asp:Label ID="Date" runat="server" CssClass="dateStyle" Text='<%# Eval ("EventDate") %>' >   </asp:Label>
  <br />

A few questions:

  1. How could I possibly reformat the EventDate (format ex:"3/23/2012 12:00:00AM") to say March 23 at 12:00AM?
  2. Is there a way for me to create the title (that I pull from the event list) as a link to edit the event? Thanks

1 Answer 1


To address the date formatting, and other binding needs, you should review the following documentation about ASP.NET databinding:

  1. http://msdn.microsoft.com/en-us/library/ms178366(v=vs.90).aspx
  2. http://msdn.microsoft.com/en-us/library/26etazsy(v=vs.90).aspx

I believe a form of the following would work:

Text='<%# Bind("EventDate", "{0:MMMM dd hh:mm}") %>'

Question 2, about setting the title link is answered in your previous question: An example of databinding the repeater control?

  • Brian Thanks for the links. They are nice and straightforward. I know in my previous question we had discussed about links, but I was wondering if you might know of any good links I could actually understand each and every line/property. I have only partially understood the code relating to the links as the code snippet was posted by a user from this forum. It would be really helpful if you could point me to a link or throw me one liner explanation on the url / link attribute/properties and how to use them. Thanks again
    – user7400
    Commented Mar 23, 2012 at 20:39
  • Start with the msdn documentation (aka the SDK) for the SPListItem class: msdn.microsoft.com/en-us/library/…. Follow the links for the properties to find out more.
    – Brian
    Commented Mar 24, 2012 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.