我想在部分视图中自动生成一个列表。
_Layout.cshtml
@Html.Partial("../Transaction/_Transaction")
事务控制器
public JsonResult transactionlist()
{
List<Transaction> TransactionList = new List<Transaction>().ToList();
string Usercache = MemoryCache.Default[User.Identity.Name] as string;
int UsercacheID = Convert.ToInt32(Usercache);
if (Usercache == null)
{
int UserID = (from a in db.UserProfiles
where a.UserName == User.Identity.Name
select a.UserId).First();
UsercacheID = UserID;
MemoryCache.Default[User.Identity.Name] = UsercacheID.ToString();
}
var Account = (from a in db.UserAccount
where a.UserId == UsercacheID
select a).First();
var DBTransaction = from a in db.Transaction
where a.AccountId == Account.AccountId
select a;
var DBTransactionList = DBTransaction.ToList();
for (int i = 0; i < DBTransactionList.Count; i++)
{
TransactionList.Add(DBTransactionList[i]);
}
ViewBag.acountsaldo = Account.Amount;
return Json(TransactionList, JsonRequestBehavior.AllowGet);
}`
我应该如何_Transaction.cshtml
编码以制作一个没有提交按钮等的简单列表?