weixin_39017744 2019-04-19 16:15 采纳率: 83.3%
浏览 397
已结题

ASP.NET MVC5项目中如何从根据EF生成的Controller中Create抓取数据并跳转?

想在插入数据后跳转到MEdit的页面,必须要抓取这个BidId.现在的问题应该是不会抓取当前的BidId。

public ActionResult Create(int bid, int sid, string sname, string btype, string btitle, string detail, int budget, DateTime bend)
        {
            var model = new BidF();
            model.BidId = bid;
            model.UserId = User.Identity.GetUserId();
            model.UserName = User.Identity.GetUserName();
            model.StoreId = sid;
            model.StoreName = sname;
            model.Title = btitle;
            model.BidType = btype;
            model.FBudget = budget;
            model.FDetail = detail;
            model.BidEnd = bend;
            return View(model);
        }

        // POST: BidFs/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "Id,BidId,UserId,UserName,Title,BidType,BidEnd,Paid,StoreId,StoreName,FBudget,FDetail,DeliveryStart,DeliveryFinish")] BidF bidF)
        {
            if (ModelState.IsValid)
            {
                db.BidFs.Add(bidF);
                db.SaveChanges();
                return RedirectToAction("MEdit","Bids");
            }

            return View(bidF);
        }
  • 写回答

1条回答

  • threenewbee 2019-04-19 16:36
    关注

    可以放在 ViewBag 或者 TempData 集合,在页面里取出来用 ViewBag,在下一个跳转里面取出来,用 TempData

    评论

报告相同问题?

悬赏问题

  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败