1、datagrid中JS函数传值问题:
columns:
{
field: 'TypeName', title: '分类名称', width: 120, sortable: true,
formatter: function (value, row, index) {
var contentDetails = "<a href='' style='text-decoration: none;' onclick='showDetailsDialog(" + row.ID + ");return false'>" + value + "</a>";
return contentDetails;
}
},
注意,以上点击事件的传值( row.ID或者value)一般都是一个int类型,如果是所传的值是字符串,则需要注意加转移字符符号。例如传值为分类名称则应该如下代码:
{
field: 'TypeName', title: '分类名称', width: 120, sortable: true,
formatter: function (value, row, index) {
var contentDetails = "<a href='' style='text-decoration: none;' onclick='showDetailsDialog(\"" + value + "\");return false'>" + value + "</a>";
return contentDetails;
}
},
2、MVC @Html.DropDownList显示默认值问题
视图页面代码:
@Html.DropDownList("ClassPre", (SelectList)ViewBag.JY_Atype_ClassPre, "==请选择上一级分类==", new { @style = "width: 60%; height: 32px" })或
@Html.DropDownList("ClassPre", (SelectList)ViewBag.JY_Atype_ClassPre, new { @style = "width: 60%; height: 32px" })
样式也可以去掉
Controller里面的代码:
ViewBag.JY_Atype_ClassPre = new SelectList(newList, "ID", "TypeName", model.ClassPre);