Jquery 使用html输入控件动态生成的表行进行编辑
我正在使用下面的代码动态生成控件并将它们的值插入数据库,它工作得非常好。问题是,我还想使用相同的视图来返回和更新记录Jquery 使用html输入控件动态生成的表行进行编辑,jquery,asp.net-mvc,razor-2,Jquery,Asp.net Mvc,Razor 2,我正在使用下面的代码动态生成控件并将它们的值插入数据库,它工作得非常好。问题是,我还想使用相同的视图来返回和更新记录 @for (var i = 0; i < Model.Attribute_Count; ++i) { <tbody id="attribute-row"> <tr> <td class="left"> @Html.TextBoxFor(x => x.A
@for (var i = 0; i < Model.Attribute_Count; ++i)
{
<tbody id="attribute-row">
<tr>
<td class="left">
@Html.TextBoxFor(x => x.AttributeName[i])
<div class="validation-area">
@Html.ValidationMessageFor(x => x.AttributeName[i])
</div>
</td>
<td class="right">@Html.TextBoxFor(x => x.Attribute_SortOrder[i])</td>
<td class="left"><a onclick="$('#attribute-row' + i).remove();" class="button">-</a></td>
</tr>
</tbody>
}
Jquery:
var attribute_row = 1;
function addattribute() {
html = '<tbody id="attribute-row' + attribute_row + '">';
html += ' <tr>';
html += ' <td class="left">@Html.TextBoxFor(x=>x.AttributeName)<div class="validation-area">@Html.ValidationMessageFor(x => x.AttributeName)</div></td>';
html += ' <td class="right"><input type="text" name="Attribute_SortOrder" id="Attribute_SortOrder"></td>';
html += ' <td class="left"><a onclick="$(\'#attribute-row' + attribute_row + '\').remove();" class="button">-</a></td>';
html += ' </tr>';
html += '</tbody>';
$('#attribute tfoot').before(html);
attribute_row++;
$('#Attribute_Count').val(attribute_row);
}
问题是什么?我粘贴的代码是用于插入的。我想用IList返回数据进行编辑。