js Array to C# List<Dictionary>(js 传参 自定义类列表 到C#)
2014-08-25 15:58
363 查看
前端:
@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>
服务端:
@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 。。。 }
相关文章推荐
- 粗谈C#里 dictionary,HashTable,List<T>,Array 的性能优缺和实现原理。
- C# 中的集合(Array/ArrayList/List<T>/HashTable/Dictionary)
- C# 中的集合(Array/ArrayList/List<T>/HashTable/Dictionary)
- C# 中的集合(Array/ArrayList/List<T>/HashTable/Dictionary)
- .Net学习 第2季05 C#面向对象 ArrayList Hashtable List<> Dictionary<>
- C#基础精华03(常用类库StringBuilder,List<T>泛型集合,Dictionary<K , V> 键值对集合,装箱拆箱)
- [C#]泛型与非泛型集合类的区别及使用例程,包括ArrayList,Hashtable,List<T>,Dictionary<Tkey,Tvalue>,SortedList<Tkey,Tvalue>,Queue<T>,Stack<T>等
- C#基础精华03(常用类库StringBuilder,List<T>泛型集合,Dictionary<K , V> 键值对集合,装箱拆箱)
- C# List<>与Array性能比较
- C#学习笔记--ArrayList?List<T>?Dictionary
- C#常见的几种集合 ArrayList,Hashtable,List<T>,Dictionary<K,V> 遍历方法对比
- 泛型中字符串转集合,(T)object,typeOf(T),LIst<T> xxx<T>();c# stringtolist
- c#简单实现二维数组和二维数组列表List<>的转置
- C# 2.0泛型-Dictionary,List用法<转载?>
- C#.Net:List<T>集合列表的Linq语句查询示例
- C# List<>与Array性能比较
- LINQ TO LIST<T> 合并列表
- [C#]泛型与非泛型集合类的区别及使用例程,包括ArrayList,Hashtable,List<T>,Dictionary<Tkey,Tvalue>,SortedList<Tkey,Tvalue>,
- c#简单实现二维数组和二维数组列表List<>的转置
- C#调用函数传参数IEnumerable<ClassA> classlist.ToList(),不会改变classlist