我正在绑定第一个更改的下拉列表。但我越来越不确定。
这是我尝试过的。在视图中
<select id="BreakOutValue" class="input1_drop" onchange="onChange()" >
</select>
<%:Html.DropDownList("DropClient", new SelectList(Model.DropClient, "Value", "Text", Model.txtDropClient), "-- Select --", new { @class = "input1_drop", id = "DropClient", @onchange = "onClientChange();"})%>
if ($("#DropClient").val() != '') {
$.ajax({
async: false,
type: 'post',
url: '/Report/BindBreakOutsWithClient_ID',
data: { Client_ID: $("#DropClient").val() },
success: function (data) {
debugger;
// var responseID = eval("(" + data + ")");
// var SystemField = responseID.List;
var items = "";
$.each(data, function (i, data) {
items += "<option value='" + data.Client_ID + "'>" + data.labelname + "</option>";
});
$("#BreakOutValue").html(items);
// $("#BreakOutValue option").remove();
// $("#BreakOutValue").append("<option value=''>-- Select --</option>");
// for (var i = 0; i < data.length; i++) {
// $("#BreakOutValue").append("<option selected='selected' value=" + data.Data[i] + ">" + data.Data[i] + "</option>");
// }
},
error: function (jqXHR, textStatus, errorThrown) {
}
});
}
return false;
}
在控制器中
public ActionResult BindBreakOutsWithClient_ID(string Client_ID)
{
int Client = Convert.ToInt32(Client_ID);
// var qBreakOut = from c in DBReport.ClientMappings orderby c.labelname ascending where c.Client_ID == Client && c.availableinui == true select c;
var BreakOut = dbReport.ClientMappings.Where(m => m.Client_ID == Client && m.availableinui == true).OrderBy(m => m.labelname).ToList();
return Json(new { Data = BreakOut });
}
但我在下拉列表中没有得到任何东西。我越来越不确定。