[英]Model returns null when passing the grid with calculation value in controller to the view
在這里我有兩個提起分配,其他提起金額。 我想在((Allocation / 100)* Amount)n中顯示第三個文件。
我有為此的代碼,但它不起作用。在查看我的模型返回Null值。在下面,我顯示了我的控制器的代碼。
public ActionResult recommendedportfolio()
{
using (var db = new WFTradeEntities1())
{
return View(db.Schema_Details.ToList());
}
}
[HttpPost]
public ActionResult recommendedportfolio(int sName)
{
using (var db = new WFTradeEntities1())
{
var tr = db.Schema_Details.ToList().Where(C => C.RID == sName).Sum((x => x.Allocation / 100));
var total = db.Schema_Details.Sum((x => x.Lum_Sum_Amount * tr )&& (x =>x.SIPAmount * tr ));
return PartialView("_PortfolioTable", total);
}
}
所以請幫幫我,我希望兩個顯示的原始n數與第四個原始n相同。在此下圖中,我可以顯示帶有output.i的查詢。我必須修復lum_Sum_Amount 25000。
在分配中,給定一些百分比50%20%30%=總計100%。 我在lum_Sum_Amount視圖中執行的操作使用分配百分比值n計算總值顯示的某個值。
首先,您需要創建一個模型
public class LINQDATA2
{
public Int64 SID { get; set; }
public Int64 RID { get; set; }
public string Schema_Name { get; set; }
public string SType { get; set; }
public string InvestmentType { get; set; }
public int Allocation { get; set; }
public int Lum_Sum_Amount { get; set; }
public float Total { get; set; }
}
因為在LINQ中不可能使用動態列。
現在執行查詢
var x = data.Select(i => new LINQDATA2 { SID = i.SID, Total = (i.Allocation / 100) * i.Lum_Sum_Amount }).ToList();
並將這個模型傳遞給局部視圖
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.