zoukankan      html  css  js  c++  java
  • asp.netMVC4(基础知识----传值问题分析)

    (1)一般在数据交互的时候,都会涉及到前后台间的相互传值,一般的情况下,方法也有多种,下面就后台定义变量往前台传值:

           以下是后台代码:

       /// <summary>
            /// 展示举报信息
            /// </summary>
            /// <returns></returns>
           // public SpeciesBLL bll = new SpeciesBLL();
            [HttpGet]
            public ActionResult Showinfomationn(string articleId, int page = 1)
            {
                Dictionary<string, object> dic = new Dictionary<string, object>();
                
                SpeciesBLL bll = new SpeciesBLL();
    
                //using (ConsultInfoBLL coninfobll = new ConsultInfoBLL())
                //{
                //    ConsultInfo dis = coninfobll.Fetch(articleId);
                //    using (TopicBLL topicbll = new TopicBLL())
                //    {
                //        Topic topic = topicbll.Fetch(dis.FClassifiedId);
                //        if (topic != null)
                //        {
                //            ViewBag.Topic = topic.FName;
                //        }
                //        else
                //        {
                //            ViewBag.Topic = "";
                //        }
                //    }
                //    dic.Add("info", dis);
                //    ViewBag.dic = dic;
                //    // return View();
                //}
                using (SpaceDiaryBLL sdb= new SpaceDiaryBLL()) {
                    IList<SpaceDiary> sd = sdb.FindALL().Where(x => x.FIsDelete == false).ToList();
                    ViewBag.Sdlist = sd;
                                         //以上是以中间变量的形式传值,把数据变量附给ViewBag的中间集合,而后在前台    var Sdlist = ViewBag.Sdlist; 形式接受 ,即完成前后台数据交互。  
    }
    using (ReportInfoBLL rbll = new ReportInfoBLL()) { // ReportInfo report = bll.Fetch(CurrentPolicy.FId); IList<ReportInfo> gov = rbll.FindALL().Where(x => x.FIsDelete == false).ToList().AsQueryable<ReportInfo>().ToPagedList(page, 5);//&&x.FId==CurrentPolicy.FId //ViewBag.list = gov; return View(gov);  //以上是以返回值传值,把数据变量返回值的视图中,在被返回视图的时候加载着把数据一样返回到前台页面 ,但是return也只能返回一个值,而 ViewBag.eggName = ? ,却可以放多个值。此方法因条件选择。

    //对于用 return 方法传值的,前台 格式为:@model IList<ReportInfo> 导入即可使用 model 数据集合。
    } }
    有些梦想是遥不可及的,除非你坚持!
  • 相关阅读:
    【剑指Offer】6、旋转数组的最小数字
    【剑指Offer】5、用两个栈实现队列
    【剑指Offer】4、重建二叉树
    python面试经典315
    shell面试经典70例
    vim编辑器使用
    bootstrap3基本了解
    Windows Server 2008允许多用户登录远程桌面
    配置远程桌面
    Python-Python及PyCharm的下载与安装
  • 原文地址:https://www.cnblogs.com/softmans/p/3311490.html
Copyright © 2011-2022 走看看