问题栏

用户名:lkj155

悬赏金:40鼠币

如何取到list类型的返回值data中某一列的值?

```onchange: function (newvalue, oldvalue) {
$.ajax({
type: 'post',
url: "/dms/productiondata/getlistbyequty",
data: { newvalue: newvalue },
async: false,
success: function (data) {

//该如何取值
}

});





``` public List<DMS_EquStopTypeModel> getlistbyequty(string newvalue)
{
List<DMS_EquStopTypeModel> list = new List<DMS_EquStopTypeModel>();
mycommonhelp mycommonhelp = new mycommonhelp();
stringbuilder sql = new stringbuilder();
sql.AppendFormat(@"select id,EquStop_Desc from DMS_EquStop
where EquStop_Type = '{0}'", newvalue);

datatable dt = DBHelp.GetDataTable(sql.ToString());

list = mycommonHelp.ConvertToList<DMS_EquStopTypeModel>(dt);
return list;

}

发布时间:2019-04-19
解答栏
  • 用户名:MASHEN

    $.each(data, function (i, item) {
    var id=item.Id;
    var desc=item.EquStop_Desc
    }
    );
    这样试试
    补充
    后台方法改成

    public actionresult getlistbyequty(string newvalue)
    {
    List<DMS_EquStopTypeModel> list = new List<DMS_EquStopTypeModel>();
    mycommonhelp mycommonhelp = new mycommonhelp();
    stringbuilder sql = new stringbuilder();
    sql.AppendFormat(@"select id,EquStop_Desc from DMS_EquStop
    where EquStop_Type = '{0}'", newvalue);

    datatable dt = DBHelp.GetDataTable(sql.ToString());

    list = mycommonHelp.ConvertToList<DMS_EquStopTypeModel>(dt);
    return json(list, JsonRequestBehavior.AllowGet);

    }

    发布时间:2019-04-19



撰写答案
请登录后再回答