按钮单击我试图将页面数据传递到另一页面。
这是我调用控制器的jquery代码
$('#btn-Print').click(function () {
debugger;
var IsValid = true;
var errorMessage = "Please notice the following errors<br /><br />";
var packageID = $('#ddlPackage option:selected').val();
if (packageID > 0)
{
var reType = "Print";
window.location.href = "/turnover/Turnover" + reType + "/" +
packageID;
}
});
这是我的控制器代码
public ActionResult TurnoverPrint(Int32 ID)//(string packageID)
{
if (Session["UserID"] != null)
{
var client = new RestClient<DataTable>(ConfigurationManager.AppSettings["ApiBaseAddress"]);
var result = client.GetApiRequest("api/TurnoverReport/get?packageID=" + ID).Result;
if (dataModel != null)
{
ViewBag.PackageName = dataModel.PackageName;
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
Dictionary<string, object> row;
if (result != null)
{
foreach (System.Data.DataRow dr in result.Rows)
{
row = new Dictionary<string, object>();
foreach (System.Data.DataColumn col in result.Columns)
{
if (col.ColumnName == "PackageDataID" || col.ColumnName == "IPC" || col.ColumnName == "From Date " || col.ColumnName == "To Date ")
{
row.Add(col.ColumnName, dr[col]);
}
else
{
row.Add(col.ColumnName, string.Format(new CultureInfo("en-IN"), "{0:n}", dr[col]));
}
}
rows.Add(row);
}
}
return View(serializer.Serialize(rows));
}
else
{
return View(null);
}
}
else
{
return RedirectToAction("Index", "Login");
}
}
这里的返回视图(serializer.Serialize(rows)); 包含必须在TurnoverPrint.cshtml视图中显示的表值列表..
row.Add(col.ColumnName,string.Format(new CultureInfo(“en-IN”),“{0:n}”,dr [col])); 此行是获取印度货币格式(货币文化)的数值
如何在视图中读取和处理列表值。我试过像
@model IEnumerable<System.Data.DataTable>
我知道这是错误的做法..
请建议我。
谢谢..