I am trying to do the following in ASP.NET 3.5. Basically, I am binding a LINQDataSource to a DataList. There is a property called ‘Deleted’ and if it is true, I want to display different markup. The following code throws errors:
<asp:DataList runat='server'> <ItemTemplate> <% If CBool(Eval('Deleted')) Then%> ... <% Else%> ... <% End If%> </ItemTemplate> </asp:DataList>
Is this possible? If not, what are the alternatives?
Why not just use the RowDataBound event and check the value of your fields then? RowDatabound is ideal for these situations where you want to alter data in a gridview based on values in the result set.
RowDataBound Event from MSDN