我可以将以下数据从我的控制器获取到我视图中的表格的最佳方法是什么。
控制器
[HttpPost]
public ActionResult PBHEP(string PC,string FC)
{
JavaScriptSerializer ser = new JavaScriptSerializer();
List<Conditions> PC_rows = ser.Deserialize<List<Conditions>>(PC);
List<Conditions> FC_rows = ser.Deserialize<List<Conditions>>(FC);
PlotXYContext plotXYContext = new PlotXYContext();
int Township = PC_rows[0].Township, Range = PC_rows[0].Range, Section = PC_rows[0].Section, Acres = PC_rows[0].Acres, Crop = Convert.ToInt32(PC_rows[0].Crop);
var query_XYCells = from TRS2Cell in plotXYContext.XYCells
where (TRS2Cell.Twnshp == Township) && (TRS2Cell.Rng == Range) && (TRS2Cell.Section == Section)
select new { TRS2Cell.Xcell, TRS2Cell.Ycell };
var output_XYCells = query_XYCells.ToList();
int XCell = Convert.ToInt32(output_XYCells[0].Xcell), YCell = Convert.ToInt32(output_XYCells[0].Ycell);
var query_CIRvalues = from aAvgCIR in plotXYContext.CIRvalues
where (aAvgCIR.X == XCell) && (aAvgCIR.Y == YCell) && (aAvgCIR.Crop == Crop)
select new { aAvgCIR.PumpNetIrrig, aAvgCIR.NonPumpNetIrrig, aAvgCIR.PumpDeepPerc, aAvgCIR.NonPumpDeepPerc };
var output_CIRvalues = query_CIRvalues.ToList();
float CIR = output_CIRvalues[0].PumpNetIrrig + output_CIRvalues[0].NonPumpNetIrrig,
Recharge = output_CIRvalues[0].PumpDeepPerc + output_CIRvalues[0].NonPumpDeepPerc,
GW_Withdrawal = (CIR - Recharge) * (Acres / 12);
ViewBag.CIR = CIR;
return View();
}
public ActionResult PBHEP()
{
return View();
}
看法
<tbody>
<tr>
<td style =" text-align:center" colspan="10"><b>Computed CIR Offsets</b></td>
</tr>
<tr>
<td style =" text-align:center"><b>Township</b></td>
<td style =" text-align:center"><b>Range</b></td>
<td style =" text-align:center"><b>Section</b></td>
<td style =" text-align:center"><b>Crop</b></td>
<td style =" text-align:center"><b>Acres</b></td>
<td style =" text-align:center"><b>CIR(IN)</b></td>
<td style =" text-align:center"><b>Recharge(IN)</b></td>
<td style =" text-align:center"><b>GW Withdrawal(AF)</b></td>
<td style =" text-align:center"><b>Platte River Depletion (Percent)</b></td>
<td style =" text-align:center"><b>Estimated Net Depletion (AF)</b></td>
</tr>
<tr>
<td style =" text-align:center" colspan="10"><b>Present Conditions</b></td>
</tr>
@(ViewBag.CIR > 0)
{
<tr>
<td style =" text-align:center"><b></b></td>
<td style =" text-align:center"><b></b></td>
<td style =" text-align:center"><b></b></td>
<td style =" text-align:center"><b></b></td>
<td style =" text-align:center"><b></b></td>
<td style =" text-align:center"><b></b></td>
<td style =" text-align:center"><b></b></td>
<td style =" text-align:center"><b></b></td>
<td style =" text-align:center"><b></b></td>
<td style =" text-align:center"><b></b></td>
</tr>
}
</tbody>
我的 VIEW 中有上表,并且希望在控制器中填充浮点值的下一行我如何将它们放在那里。最佳做法是什么?
我尝试使用 ViewBag 更新一个值,但无法更新我的 UI
先感谢您!