Reputation: 4976
Is there a way to identifying a cell location for a dynamic HTML Table in a partial view?
Dynamic Table:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<div>
<table>
<tr>
<th>
Student ID
</th>
<th>
Quarter
</th>
<th>
Subject
</th>
<th>
Section
</th>
</table>
</div>
<div>
<table>
<% if (Model != null)
foreach (var item in Model) { %>
<tr>
<td>
Html.Encode(item.StudentID)
</td>
<td>
Html.Encode(item.Quarter)
</td>
<td>
Html.Encode(item.Subject)
</td>
<td>
Html.Encode(item.Section)
</td>
<%}%>
</table>
</div>
Thanks in advance
Upvotes: 0
Views: 123
Reputation: 1524
If i understand correctly?
$('td').click(function(){
var row = $(this).parent().index();
var cell = $(this).index();
$(this).text(row + '/' + cell);
}).trigger('click')
Upvotes: 1