2016-11-11 24 views
2

這裏我有兩個歸檔是分配,其他歸檔是數量。我想在第三個提交的((Allocation/100)* Amount)n顯示第三個提交。當控制器中的計算值通過網格傳遞給視圖時,Model返回null

我有代碼對於這個,但它不working.in查看我的模型return null.here下面我顯示我的控制器的代碼。

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的這個下面的圖片,我可以顯示我的查詢與output.i必須解決lum_Sum_Amount 25000這一數額中所述原料相同計數.. 。
在分配中,有些%給出了50%20%30%=總共100%。 我在視圖lum_Sum_Amount中計算分配百分比值n得到總值中顯示的某個值。所有

enter image description here

+0

添加一些標記你的問題涉及到技術 –

+0

@KrutarthPatel餘米uisng asp.net MVC(模型 - 視圖 - 控制器) –

+1

請修改您的問題,並提出明確的問題。 –

回答

0

首先,你需要創建一個模型

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(); 

進行查詢,這種模式傳遞給局部視圖

+0

它可以請求一件事int分配n int lum_sum_Amount我有,如果通過錢,然後在控制器,我可以召集???如果是的話那麼怎麼樣? –

+0

更改類型根據您的需要 –

+0

Devlopers但在映射時間在我的項目中給出了錯誤 –

相關問題