I am using a strongly typed user control in one of the view. The coding is as follows:
This is the call in my View:
<table>
<%
for (int i = 0; i < ((List<string>)ViewData["MyProjects"]).Count; i++)
{
string viewIndex = "MyTasks" + i.ToString();%>
<tr>
<td>
<%Html.RenderPartial("ProjectTasks", ViewData[viewIndex]); %>
</td>
</tr>
<% } %>
</table>
My user control has the following code:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<List<Application_Service.DTOs.TaskDTO>>" %>
<%if(Model.Count > 0){ %>
<table>
<tr>
<td>Task Name</td>
<td>Task Status</td>
</tr>
<% foreach (var item in ViewData.Model) {%>
<tr>
<td>
<%:Html.Label(item.TaskName); %>
</td>
<td>
<%:Html.Label(item.TaskStatus.ToString());%>
</td>
</tr>
<%} %>
</table>
<%} %>
The problem is that I get an error while trying to call bind the model in user control. I am not sure what is the problem here.
Error Message:
"ProjectTasks.ascx(14): error CS1026: ) expected". at the Html.RenderPartial call.