I think the correct terminology ...
Basically, I have a repeater control and a Linq query that retrieves some elements. Normally, I would bind the data directly to the query and use Eval to populate the template with the results.
However, it does not pass in the correct format - for example, if EndDate is null (is it DateTime?), Then I want to replace it with "Present". I use only a couple of properties in the query result objects.
I am wondering if there is such a solution as:
[pseudo madeup code] var query = getResults(); List<anonymous> anonList = new List(); foreach (var q in query) { string myEndDate = ""; if (q.EndDate.HasValue) { myEndDate = q.EndDate.ToString(); } else { myEndDate = "Present"; } anonList.items.add(new { name=q.name, enddate=myEndDate }; } repeater.Datasource = anonList;
then
<div><%#Eval("enddate")%></div>
Nibblypig
source share