zoukankan      html  css  js  c++  java
  • 查询数据(后台到前台传递数据,显示数据)

    前台相关代码:

    头部导入代码:

    *@
    @model IDictionary<string, object>
    @{
        var fuid = ViewContext.RouteData.Values["id"].GetString();
        var list = (PagedList<SpaceFriend>)Model["list"];
        var spaceTeam = (IQueryable<SpaceTeam>)Model["spaceteam"];
        ViewBag.Title = "空间好友表";
        ViewBag.ItemMenu = "Home";
        Layout = "~/Areas/PersonalSpace/Views/Shared/master/_LayoutIndex.cshtml";
        string ViewMode = Request["view"];
        string Durl = ViewBag.Durl;
        if (string.IsNullOrEmpty(ViewMode))
        {
            ViewMode = "list";
        }
        string cId = "";
        if (!string.IsNullOrWhiteSpace(Request["cid"]))
        {
            cId = Request["cid"];
        }
    
        string order = Request["order"];
        if (string.IsNullOrEmpty(order))
        {
            order = "0";
        }
    
        string strUserId = ViewBag.UserId;
        string loginUserId = LoginBLL.GetCurrentUserFid();
        ViewData["UserId"] = strUserId;
    }

    使用循环调用相关代码:

      @using (Html.BeginForm())
        {
            <fieldset style=" 100%">
                @*            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="table_head_bg">
                    <tr>
                        <td>
                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                           
                            </table>
                        </td>
                    </tr>
                </table>*@
                <table width="100%" border="0" cellpadding="0" cellspacing="0" id="tbs" class="table">
                    <tbody>
                        @*            <div style=" 100%; border: 1px; float: none; margin-top: 10px; margin-bottom: 10px;
                            padding-right: 20px" class="table_head_bg">
                            好友名称:<input type="text" id="FName" name="FName" style="border: 1px solid #c6c6c5;
                                height: 20px" />&nbsp;&nbsp;
                            <input type="submit" class="input_bg" value="查询好友" id="btn" /></div>*@
                        @{
            foreach (var friend in list)
            {
    @*            <tr class="right-table"> 
                <td width = "40%" align="center"><a href="/Home/Home/Index/@friend.FFriendId" target="_blank">@friend.FFriendName</a></td> 
                <td width = "30%" align="center">@friend.FTeamId</td>
                    <td align="center" class="right_cz_green"> 
                    @if (friend.FType != null && (friend.FType.Trim() == "1" || friend.FType.Trim() == "2"))
                    {
    
                    }
                    else
                    { 
                        <text><a href = "#" class = "friend" name = "@friend.FId" id="btn_SpaceFriend_MoveTeam" >分组</a>&nbsp; &nbsp;</text>
                    }
                  <a href = "#" id = "del" name = "@friend.FId"  id="btn_SpaceFriend_Del">解除好友关系</a>
                    </td>  
                </tr>*@
      
                var fTypeId = friend.FFriendId;
                var userId = LoginBLL.GetCurrentUserFid();
                using (SpaceFriendBLL bll = new SpaceFriendBLL())
                {
                    UserInfoBLL bb = new UserInfoBLL();
                    //  List<UserInfo> utList = bb.FindALL().Where(temp => temp.FId == fTypeId).ToList();
                    UserInfo utList = new UserInfo();
    
                    //    string FUserImgSmall =    && utList.Count > 0  ---------------   /@friend.FFriendId
                    if (utList != null)
                    {
                            <li style="float: left; line-height: 60px; border-bottom-color: #ddd; border-bottom- 1px;
                                border-bottom-style: dashed; margin-bottom: 5px; overflow: hidden;">
                                <div class="photo_box">
                                    <div class="photo_box_info">
                                        <!-- photo_box_info_img  开始-->
                                        <div class="photo_box_info_img left">
                                            <div class="comments_item_bd left">
                                                <div class="ui_avatar_tu">
                                                    @if (friend.FFriendId != null)
                                                    {
                                                        string ImageUrl = String.IsNullOrEmpty(utList.FUserImgSmall) ? "/Images/uploadimg_default.jpg" : utList.FUserImgSmall;
                                                        <img src="@(ImageUrl)" width="60" height="65" style="margin: 5px; float: left;" alt="好友图片" /><br />
                                                        <div class="comments_content left">
                                                            姓 名: <a href="@Durl/@(friend.FFriendId)" target="_blank">@friend.FFriendName
                                                            </a>
                                                            <div class="comments_op left">
                                                                <span class=" text"><a href = "#" class = "friend" name = "@friend.FId" id="btn_SpaceFriend_MoveTeam" >
                                                                    分组</a></span></div>
                                                            <div class="comments_op left">
                                                                <span class=" text"><a href = "#" id = "del" name = "@friend.FId"  id="btn_SpaceFriend_Del">
                                                                    解除好友关系</a></span></div>
                                                        </div>
                                                
                                                    }
    
                                                    else
                                                    {
                                                        <img src="/images/personalSpace/icon_default.gif" width="60" height="65" style="margin: 5px;
                                                            float: left;" alt="好友图片" />
                                                    }
                                                </div>
                                            </div>
                                        </div>
                                        <!-- photo_box_info_img  结束-->
                                    </div>
                                </div>
                            </li>
           
                    }
    
                }
    
            }
                            
                        }
    
                    </tbody>
                                    <!--添加分页-->
                    <tfoot>
                        <tr style="border-left:transprant">
                            <td colspan="4" style="padding-top: 20px; vertical-align: middle;">
                                <div class="pageBottom clear_box snPages">
                                    <div class="pager">
                                        @Html.Pager(list, new PagerOptions { NumericPagerItemCount = 3, ShowMorePagerItems = true, ShowFirstLast = false, PageIndexParameterName = "page", CurrentPagerItemWrapperFormatString = "<span class="cpb">{0}</span>", NumericPagerItemWrapperFormatString = "<span class="item">{0}</span>", AlwaysShowFirstLastPageNumber = true }, "PersonalSpace_default", null)
                                    </div>
                                    <div class="clear">
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </tfoot>
                </table>
            </fieldset>
        
            
        }

    查询数据的后台代码:

        [HttpGet]
            [SupportFilter(FCode = "PersonalSpace_SpaceFriend_List")]//判断页面是否有权限,FCode 调用枚举,没有的自己补,格式为:Areas_Controller_Action,例如:Heart_AgrBaseArea_Add
            public ActionResult List(string cid, string keyword, string Durl,string pid, int page = 1, int pageSize = 20) //, string keyword
            {
                IsAuthorityButton("PersonalSpace_SpaceFriend_List");
                IDictionary<string, object> dic = new Dictionary<string, object>();
    
                using (UserInfoBLL ubll = new UserInfoBLL())
                {
                    //  if (ui.FUserTypeId == "6daf56c8571e451ca017aaeb47e70a22")//ui.FRoleId    f5450e699b414c9a8dfd3ebf9022d7a1
                   // SpaceFriend sf = new SpaceFriend();
                   // string FFriendId = sf.FFriendId;
    
                    IQueryable<UserInfo> ui = ubll.FindALL().Where(x => x.FRoleId == pid);
                    // if (ui.FRoleId.Contains("f5450e699b414c9a8dfd3ebf9022d7a1"))
                    if (ui.Equals("f5450e699b414c9a8dfd3ebf9022d7a1"))
                    {
                        //  Durl = "/CompanySpace/SpaceFriend/List";
                        Durl = "personal/Home/Home/Index";     //personal/Home/Home/Index   /CompanySpace/Home/Index
    
                    }
                    else
                    {
                        // Durl = "/Personal/Space/SpaceFriend/List";   //personal/Home/Home/Index   /CompanySpace/Home/Index
                        Durl = "/Personal/Home/Home/Index";
                    }
                    ViewBag.Durl = Durl;
    
                }
    
    
               // var pageList = list.Skip((page - 1) * pageSize).Take(pageSize).ToList();
               // var pageList2 = new PagedList<UserFavorite>(pageList, page, pageSize, pageList.Count());
    
                var result = bll.GetSelSpaceFriends(CurrentUser.FId, cid, keyword).AsQueryable<SpaceFriend>().ToPagedList(page, 5);//, keyword
              //  ViewBag.did = did;
                using (SpaceTeamBLL teambll = new SpaceTeamBLL())
                {
                    dic.Add("list", result);
                    using (SpaceTeamBLL teambl = new SpaceTeamBLL())
                    {
                        IQueryable<SpaceTeam> team = teambll.FindALL().Where(x => x.FUserId == CurrentUser.FId);
                        dic.Add("spaceteam", team);
                    }
                    return PartialView(dic);// View(dic);
                }
            }
    有些梦想是遥不可及的,除非你坚持!
  • 相关阅读:
    Nodejs下载和第一个Nodejs示例
    永久关闭Win10工具栏的TaskbarSearch控件
    对称加密,非对称加密,散列算法,签名算法
    【转】TTL和RS232之间的详细对比
    zlg核心板linux系统中查看系统内存等使用信息
    Power BI后台自动刷新数据报错 The operation was throttled by Power BI Premium because there were too many datasets being processed concurrently.
    剪切板和上传文件内容获取
    CSS, LESS, SCSS, SASS总结
    文字程序
    electron 打包“ERR_ELECTRON_BUILDER_CANNOT_EXECUTE”
  • 原文地址:https://www.cnblogs.com/softmans/p/3303158.html
Copyright © 2011-2022 走看看