I have a listview control on an .aspx page. Inside this view list, I want to check the Type property, which comes from the database. here is a sample code:
<ItemTemplate> <%# if(Convert.ToInt32(DataBinder.Eval(Container.DataItem,"Type")) == 0){ %> <tr class="item"> <td> <%# Convert.ToDateTime(Eval("WorkDate")).ToShortDateString() %> </td> <td style="text-align: center;"> <%# Eval("SkillName") %> </td> </tr> <%# } else if (Convert.ToInt32(DataBinder.Eval(Container.DataItem,"Type")) == 1) {%> <tr class="item"> <td colspan="2"> <strong><%# Convert.ToDateTime(Eval("WorkDate")).ToShortDateString() %></strong> </td> </tr> <% } %> </ItemTemplate>
As a last resort I tried to use DataBinder.Eval (), but I get the exception "Expected class, delegation, enumeration, interface or structure". What can i do wrong? Writing a function in encoding is not an option for me. Is there any way to achieve this?
source share