MVC 分页获取数据 及点选按钮

@model PagedList<Lyxm.Entity.Suggestion>
@using Webdiyer.WebControls.Mvc


<div>
    <ul class="breadcrumb">
        <li>
            @Html.ActionLink("基础维护", "", "")
            <span class="divider">-</span>
        </li>
        <li>
            @Html.ActionLink("特色互动", "")
        </li>
    </ul>
</div>


<div class="row-fluid sortable">
    <div class="box span12">
        <form class="form-horizontal" method="post">
            @Html.AntiForgeryToken()
            @Html.ValidationSummary(true)
            <div class="box-header well" data-original-title>
                <h2><i class="icon-edit"></i>&nbsp;特色互动主题详情</h2>
                <div class="box-icon">
                </div>
            </div>
            <div class="box-content">

                @*@Html.ValidationSummary(true)*@

                <fieldset>
                    <legend>Suggestion</legend>

                    <div class="control-group">
                        <label class="control-label" for="typeahead">征集主题</label>
                        <div class="controls">
                            <input class="input-xlarge disabled" type="text" value="@ViewBag.SuggestionSubject.Title" disabled="" style="width:600px;">
                        </div>
                    </div>

                    <div class="control-group">
                        <div style="float: left;">
                            <label class="control-label" for="typeahead">作者</label>
                            <div class="controls">
                                <input class="input-xlarge disabled" type="text" value="@ViewBag.SuggestionSubject.Author" disabled="">
                            </div>
                        </div>
                        <div>
                            <label class="control-label" for="typeahead" style="margin-right: 20px;">征集部门</label>
                            <div class="controls">
                                <input class="input-xlarge disabled" type="text" value="@ViewBag.SuggestionSubject.Department" disabled="">
                            </div>
                        </div>
                    </div>

                    <div class="control-group">
                        <div style="float: left">
                            <label class="control-label" for="typeahead">截止时间</label>
                            <div class="controls">
                                <input class="input-xlarge disabled" type="text" value="@ViewBag.SuggestionSubject.BeginTime - @ViewBag.SuggestionSubject.EndTime" disabled="">
                            </div>
                        </div>
                        <div>
                            <label class="control-label" for="typeahead" style="margin-right: 20px;">发布</label>
                            <div class="controls">
                                <input class="input-xlarge disabled" type="checkbox" checked="@ViewBag.SuggestionSubject.Published" disabled="">
                            </div>
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">正文</label>
                        <div class="controls">
                            <textarea id="Content" disabled="disabled">@ViewBag.SuggestionSubject.Content
                            </textarea>
                            @*@Html.TextArea(ViewBag.SuggestionSubject.Content, new { disabled = "" })*@
                        </div>
                    </div>
                </fieldset>

            </div>


            <div class="box-header well" data-original-title>
                <h2><i class="icon-edit"></i>&nbsp;特色互动回复列表</h2>
                <div class="box-icon">
                </div>
            </div>
            <div class="box-content">

                <fieldset>
                    <legend>Suggestion</legend>

                    @foreach (var item in Model)
                    {
                        <div class="control-group">
                            <div style="float: left">
                                <label class="control-label" for="typeahead">@(Model.IndexOf(item) + 1)
                                    . 姓名</label>
                                <div class="controls">
                                    <input class="input-xlarge disabled" type="text" value="@item.Name" disabled="">
                                </div>
                            </div>
                            <div>
                                <label class="control-label" for="typeahead" style="margin-right: 20px;">电话</label>
                                <div class="controls">
                                    <input class="input-xlarge disabled" type="text" value="@item.Telephone" disabled="">
                                </div>
                            </div>
                        </div>
                        
                        <div class="control-group">
                            <div style="float: left">
                                <label class="control-label" for="typeahead">电子邮件</label>
                                <div class="controls">
                                    <input class="input-xlarge disabled" type="text" value="@item.Email" disabled="">
                                </div>
                            </div>
                            <div>
                                <label class="control-label" for="typeahead" style="margin-right: 20px;">发表时间</label>
                                <div class="controls">
                                    <input class="input-xlarge disabled" type="text" value="@item.AddDate" disabled="">
                                </div>
                            </div>
                        </div>
                        <div class="control-group">
                            <div style="float: left">
                                <label class="control-label" for="typeahead">是否通过审核</label>
                                <div class="controls">

                                    <input class="input-xlarge disabled" type="text" value="@(item.Checked == true ? "审核通过" : "未通过")"  disabled="" style="width:60px; text-align:center;" />
                                    @*<input type="checkbox" name="inputChecked" value="@item.Checked.ToString()" />*@

                                    &nbsp 通过 &nbsp<input id="@(Model.IndexOf(item))radioChecked" type="radio" name="@(Model.IndexOf(item))radioChecked" value="true"/>
                                    &nbsp 不通过 &nbsp<input id="@(Model.IndexOf(item))unradioChecked" type="radio" name="@(Model.IndexOf(item))radioChecked"  value="false"/>

                                    @*原来的 @Html.Editor(item.Checked.ToString());
                                    @Html.ValidationMessage(item.Checked.ToString())*@
                                </div>
                            </div>
                        </div>
                        
                        <div class="control-group">
                            <label class="control-label">正文</label>
                            <div class="controls">
                                <textarea id="Content" class="input-xlarge disabled" rows="4" style="width: 600px;" disabled="disabled">@item.Content
                            </textarea>
                            </div>
                        </div>

                    }

                    <div class="row-fluid">
                        <div class="span12">
                            <div class="dataTables_info" id="DataTables_Table_0_info">显示 @Model.StartRecordIndex - @Model.EndRecordIndex 条,共 @Model.TotalItemCount 条</div>
                        </div>

                        <div class="span12 center">
                            <div class="dataTables_paginate paging_bootstrap pagination">
                                @Html.Pager(Model, new PagerOptions
                                   {
                                       PageIndexParameterName = "page",
                                       ContainerTagName = "ul",
                                       PagerItemWrapperFormatString = "<li>{0}</li>",
                                       CurrentPagerItemWrapperFormatString = "<li class=\"active\"><a>{0}</a></li>",
                                       PagerItemsSeperator = ""
                                   })
                            </div>
                        </div>
                    </div>
                    <div class="form-actions">
                        <button type="submit" class="btn btn-success btn-large">保存</button>
                        <a href=" @Url.Action("Index")" class="btn btn-primary btn-large">返回列表</a>
                    </div>
                </fieldset>
            </div>

        </form>
    </div>
</div>



@*增加编辑器js控件*@
@section featured {
    @Scripts.Render("~/bundles/jqueryval")
    <script src="~/Scripts/kindeditor-4.1.10/kindeditor.js"></script>
    <script src="~/Scripts/kindeditor-4.1.10/lang/zh_CN.js"></script>
    <script>
        KindEditor.ready(function (K) {
            window.editor = K.create(‘#Content‘, {
                width: ‘700px‘,
                height: ‘350px‘,
                uploadJson: ‘@Url.Action("UploadFile", "Upload")‘,
                allowFileManager: false
            });
            window.editor.readonly(true);
        });
    </script>
}

 

Controller

 public ActionResult SuggestionIndex(int id, int? page, string search = "")
        {
            var subject = busi.GetSuggestionSubjectById(id);
            ViewBag.SuggestionSubject = subject;

            int pageIndex = page ?? 1;
            if (!string.IsNullOrWhiteSpace(search))
            {
                if (!search.Equals(ViewBag.searchContent))
                {
                    pageIndex = 1;
                }
            }
            int pageSize = ManageSetting.PageSize;
            int skipCount = (pageIndex - 1) * pageSize;
            int total = 0;
            var atcs = busi.GetSuggestionList(id, pageIndex, pageSize, out total, search).ToPagedList(pageIndex, pageSize);
            atcs.CurrentPageIndex = pageIndex;
            atcs.TotalItemCount = total;

            return View(atcs);
        }

        //post Suggestion/SuggestionIndex/3?notice=修改成功!&page=1
        [HttpPost]
        [ValidateInput(false)]
        [ValidateAntiForgeryToken]
        public ActionResult SuggestionIndex(SuggestionSubject suggestionsubject,int?page,string search="")
        {

            int pageIndex = page??1;
            if (!string.IsNullOrWhiteSpace(search))
            {
                if (!search.Equals(ViewBag.searchContent))
                {
                    pageIndex = 1;
                }
            }
            int pageSize = ManageSetting.PageSize;
            int skipCount = (pageIndex - 1) * pageSize;
            int total = 0;
            List<Suggestion> suggestionList = busi.GetSuggestionList(suggestionsubject.Id, pageIndex, pageSize, out total, search).ToPagedList(pageIndex, pageSize);

            for (int i = 0; i < suggestionList.Count; i++)
            {
                if (!string.IsNullOrEmpty(Request.Form[i+"radioChecked"]))
                {
                    suggestionList[i].Checked = Convert.ToBoolean(Request.Form[i + "radioChecked"]);
                }
                else if (suggestionList[i].Checked == true)
                {
                    suggestionList[i].Checked = true;
                }
                else {
                    suggestionList[i].Checked = false;
                }

                suggestionList[i].ModUserId = GetUserInfo().Id;
                busi.UpdateSuggestion(suggestionList[i]);

            }
            return RedirectToAction("SuggestionIndex", new { id = suggestionsubject.Id, notice = Server.UrlEncode("修改成功!"), page = pageIndex });
        }

MVC 分页获取数据 及点选按钮,布布扣,bubuko.com

MVC 分页获取数据 及点选按钮

上一篇:JQuery中$.ajax()方法参数详解


下一篇:CentOS 中 redis 安装