這將取決於你怎麼樣了,比爾特你的表很大。但這裏有一個非常簡單的例子:
1 - 把你的洞表放在一個表格中;
2 - 確定每個數據單元的領域與它的「coorditate」
像這樣:
<%: using(form = html.Form("UpdateGrid")) { %>
<table>
<% for (int r = 0; r < rowCount; r++) { %>
<tr>
<% for (int c = 0; c < columnCount; c++) { %>
<td><%: html.TextBox(string.format("cell_{0}_{1}",r,c)) %></td>
<% } %>
</tr>
<% } %>
</table>
<% } %>
這只是一個示例代碼(我不知道這是否會成功,因爲它是)但它會給你一個想法。 如果你想有一個像Excel的地址,你可以這樣做:
<td><%: html.TextBox(string.format("{1}{0}",(char)(r + 'A'),c + 1)) %></td>
要從您可以使用下面的錐控制器訪問表信息:
public ActionResult UpdateGrid(FormCollection form) {
// ... Some initialization
for (int r = 0; r < rowCount; r++) {
for (int c = 0; c < columnCount; c++) {
var cellValue = form[string.format("{1}{0}",(char)(r + 'A'),c + 1)]; // Excell like format
// Add your manipulation here;
}
}
// ... Continue your controller implementation
}
有沒有什麼你停止使用這兩種技術在同一個項目中。 – Lazarus 2010-08-12 13:22:46