前端:
@model ZACF.Site.Mvc.ViewModels.My.InterestAutoCashList
<div class="AutoCashList">
<table>
<tr>
<th width="20%;" style="font-weight:lighter;"><input type="checkbox"/> 全选</th>
<th>月息宝</th>
<th width="20%">自动提现</th>
</tr>
@foreach (var item in Model.AutoCashList)
{
<tr>
<td><input type="checkbox" value="@item.ID"/></td>
<td>@item.OrderId</td>
<td>@(item.IsAutoCash == "01" ? "已开启" : "已关闭")</td>
</tr>
}
</table>
<div style="margin-top:30px;">
<input id="btnOpen" type="button" value="开启"/>
<input id="btnClose" type="button" value="关闭"/>
</div>
</div>
<script type="text/javascript">
$("#btnOpen").click(function () {
var list = new Array();
$(".AutoCashList table td").find("input[type='checkbox']").each(function () {
list.push({ interestUserId: $(this).val(),isChecked:$(this).prop("checked"),oldChecked:$(this).next("td").html()});
});
$.ajax({
url: "/My/InterestAutoCashOpen",
data: { listData: list },
type: "post",
success: function (data) {
}
});
});
</script>
服务端:
public ActionResult InterestAutoCashOpen(List<Dictionary<string,string>> listData)
{
foreach (var item in listData)
{
string interestUserId = item["interestUserId"];
bool isChecked = bool.Parse(item["isChecked"]);
。。。
}
return 。。。
}
本文介绍如何将JavaScript数组转换为C#的List<Dictionary>类型,涉及前端与服务端的数据交互,重点讲解js参数传递及C#自定义类列表的接收处理。
720

被折叠的 条评论
为什么被折叠?



