Question

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
Was it helpful?

Solution

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?

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top