Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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?

share|improve this answer
    
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 Mar 23 '12 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 Mar 24 '12 at 14:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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