Я хочу показать Specifi c Данные продукта через ID, Через Master Grid я нажимаю ссылку и передаю данные на другую страницу. Я использую этот метод, но данные не отображаются в From и Grid. Любой эксперт подскажет где я не прав. Я показал ответ JSON. Я также отлаживаю данные кода, которые отображаются, но не отображаются в текстовом поле и в таблице.
C#
public ActionResult GetProduct_Detail(int id)
{
var resultProdD = _IProducts.GetProductByID(id);
JsonSerializerSettings jss = new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore };
var result = JsonConvert.SerializeObject(resultProdD, Formatting.Indented, jss);
return Json(result, JsonRequestBehavior.AllowGet);
}
Json Ответ
{
"listProducts":{
"Customers":[
],
"P_Color":{
"Products":[
],
"C_ID":3,
"C_Name_OR_Code":"Green "
},
"P_Size":{
"Products":[
],
"S_ID":2,
"S_Size":"MediumNa "
},
"ProductDetail":{
"ProductID":6,
"PDescription":"s",
"Model":"s ",
"Condition":"s ",
"OS":"s",
"DualSim":"s ",
"TouchScreen":"ss ",
"ScreenSize":"s ",
"ProcessorType":"s ",
"Camera":"s ",
"RAM":"s ",
"InternalMemory":"s ",
"Wifi":"s ",
"BatteryLife":"s ",
"Discount":54.0,
"Other":"s",
"ImageUrl":"~/upload/20095729TERI NAZAR Song LYRICS.jpg"
},
"ProductType":{
"Products":[
],
"PType_ID":1,
"P_Name":"mobile ",
"P_Description":"mobile",
"Active":false
},
"ProductID":6,
"PName":"s ",
"UnitWeight":0.0,
"UnitInStock":4.0,
"P_SizeID":2,
"P_Color_ID":3,
"PType_ID":1,
"ManificturedPrice":52.0
},
"listProductDetails":[
{
"Product":{
"Customers":[
],
"P_Color":{
"Products":[
],
"C_ID":3,
"C_Name_OR_Code":"Green "
},
"P_Size":{
"Products":[
],
"S_ID":2,
"S_Size":"MediumNa "
},
"ProductType":{
"Products":[
],
"PType_ID":1,
"P_Name":"mobile ",
"P_Description":"mobile",
"Active":false
},
"ProductID":6,
"PName":"s ",
"UnitWeight":0.0,
"UnitInStock":4.0,
"P_SizeID":2,
"P_Color_ID":3,
"PType_ID":1,
"ManificturedPrice":52.0
},
"ProductID":6,
"PDescription":"s",
"Model":"s ",
"Condition":"s ",
"OS":"s",
"DualSim":"s ",
"TouchScreen":"ss ",
"ScreenSize":"s ",
"ProcessorType":"s ",
"Camera":"s ",
"RAM":"s ",
"InternalMemory":"s ",
"Wifi":"s ",
"BatteryLife":"s ",
"Discount":54.0,
"Other":"s",
"ImageUrl":"~/upload/20095729TERI NAZAR Song LYRICS.jpg"
}
],
"ProductID":0,
"PName":null,
"UnitWeight":0.0,
"UnitInStock":0,
"P_SizeID":0,
"ProductSize":null,
"P_Color_ID":0,
"ProductColor":null,
"PType_ID":0,
"ProductType":null,
"ManificturedPrice":0.0,
"PDescription":null,
"Model":null,
"Condition":null,
"OS":null,
"DualSim":null,
"TouchScreen":null,
"ScreenSize":null,
"ProcessorType":null,
"Camera":null,
"RAM":null,
"InternalMemory":null,
"Wifi":null,
"BatteryLife":null,
"Discount":0,
"Other":null,
"ImageUrl":null
}
Функция
<script type="text/javascript">
$(document).ready(function () {
debugger;
var baseUrl = (window.location).href; // You can also use document.URL
var id = baseUrl.substring(baseUrl.lastIndexOf('=') + 1);
list_ProductDetail(id);
});
function list_ProductDetail(id)
{
$.ajax({
url: "/Items/GetProduct_Detail",
type: "GET",
contentType: "application/json;charset=utf-8",
dataType: "json",
data: { id: id },
success: function (result) {
$('#PName').val(result.PName);
$('#ManificturedPrice').val(result.ManificturedPrice);
$('#UnitWeight').val(result.UnitWeight);
$.each(result, function (key, item) {
var html = '';
html += '<tr>';
html += '<td>' + item.ProductID + '</td';
html += '<td>' + item.OS + '</td>';
html += '<td>' + item.PrcessorType + '</td>';
html += '<td>' + item.RAM + '</td>';
html += '<td>' + item.ScreenSize + '</td>';
html += '<td>' + item.TouchScreen + '</td>';
html += '<td>' + item.BatteryLife + '</td>';
html += '<td>' + item.Camera + '</td>';
html += '<td>' + item.Model + '</td>';
html += '<td>' + item.Condition + '</td>';
html += '<td>' + item.Discount + '</td>';
html += '<td><a class="menu-action rounded-btn btn menu-icon vd_bd-grey vd_grey" data-toggle="tooltip" href="#" onclick="return GetProductDetail(' + item.ProductID + ')"><i class="fa fa-pencil"></i></a> | <a href="#" onclick="Delete(' + item.ProductID + ')"><i class="fa fa-thrash"></i></a></td>';
});
$('tbody').append(html);
},
error: function (errormessage) {
alert(errormessage.responseText);
},
});
}
</script>