前台(提交方法):
$("#btnQueDing").click(function () {
var rows = $(‘#dg‘).datagrid(‘getData‘);
if ($("#iptZiDingYiMuBanMingCheng").attr("value") == "") {ZhongWenMingCheng
$.messager.alert(‘警告‘, ‘请先填写模板名称!‘);
return;
} else {
$.ajax({
type: "POST",
url: "/KaoHeMuBan/AddZiDingYiMuBan?MingCheng=" + $("#iptZiDingYiMuBanMingCheng").attr("value") + "&MuBanLeiXing=" + $(‘#selZiDingYi‘).combobox(‘getText‘) + "&BeiZhu=" + $("#ZiDingYiBeiZhu").attr("value") + "&LieLeiXing=" + JSON.stringify(rows.rows),
//data: "MingCheng=" + $("iptZiDingYiMuBanMingCheng").attr("value") + "&MuBanLeiXing=" + $(‘#selZiDingYi‘).combobox(‘getText‘) + "&BeiZhu=" + $("#BeiZhu").attr("value") + "&LieLeiXing=" + dgdata,
success: function (msg) {
ShuaXin();
$.messager.alert(‘提示‘, msg);
}
})
}
})
后台接收方法:
public class ccccccc
{
public string ZhongWenMingCheng { get; set; }
public string KaoPingXiangLeiXing { get; set; }
}
public string AddMuBan(string LieLeiXing)
{
try
{
#region MyRegion添加
List<ccccccc> jsonlist = new List<ccccccc>();//实例化
List<MuBan> listxm = JsonConvert.DeserializeObject<List<MuBan>>(LieLeiXing);//json反序列操作
for (int i = 0; i < listxm.Count; i++)
{
MuBan ximu = new MuBan();
ximu.MingCheng= listxm[i].MingCheng;
ximu.LeiXing = listxm[i].LeiXing;
tmbxmBLL.Insert(ximu);//添加方法
}
return "添加成功";
#endregion
}
catch
{
return "添加失败";
}
}