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

    评论

报告相同问题?

悬赏问题

  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名