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

时间: 2024-12-09 07:09:14

MVC 分页获取数据 及点选按钮的相关文章

使用ivx实现分页获取数据的经验总结

在实际案例中我们经常需要展示一些数据,而这些数据都是存放在后台的数据库之中的而且可能数量庞大,在前台的界面中一下子全都展示出来肯定是不现实的,另外一次性让后台传输如此多的数据到前台也会有很大的延迟,使用户体验较差.因此,我们就需要采取一种分页的方式来少量多次的获取数据,这样用户每次操作之后都能很快得到反馈,同时前台也不用存放很多数据造成案例卡顿,今天就来说说如何实现这种分页效果.1.组件结构Demo中的结构比较简单,页面下放置了一个列作为案例主体,列内添加了一个分页组件,还有一个for容器用于循

MVC—实现ajax+mvc异步获取数据

之前写过ajax和一般处理程序的结合实现前后台的数据交换的博客,如今做系统用到了MVC,同一时候也用到了异步获取数据. ajax+一般处理程序与MVC+ajax原理是一样的在"URL"中前者写的一般处理程序的名字.而后者写到Controller中须要调用的方法. Controller中的设计 using System.Collections.Generic; using System.Web.Mvc; namespace mvcAjaxByAjax.Controllers { //考试

NHibernte 4.0.3版本中,使用Queryover().Where().OrderBy().Skip().Take()方法分页获取数据失败

问题代码如下: var result=repository.QueryOver<modal>() .Where(p=>p.Code==Code) .OrderBy(p=>p.ID).Asc .Skip(pageSize*(page-1)) .Take(pageSize).List() 当设置page=1,pageSize=10时,获取数据正常:当设置的page大于1时,获取不到任何数据:原因尚未找到. 解决办法:修改代码如下 var result= repository.Query

分页“真分页”获取数据

对于初学的新手来说,做数据分页的时候,经常是去网上下载个控件,所谓控件分页,有的人认为很好,因为方便,但是对于老鸟来说 控件分页查询效率太低,在实际工作中,也会带来致命的弱点,所以,我们一般采用真分页,部分查询,效率没得说!! 石家庄ReactNative交流群 526955818欢迎大家加入 using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threadi

php表单中如何获取单选按钮与复选按钮的值

php代码中获取表单中单选按钮的值:(单选按钮只能让我们选择一个,这里有一个"checked"属性,这是用来默认选取的,我们每次刷新我们的页面时就默认为这个值.) 例:<form name="myform" action="" method="post"> 性别: <input type="radio" name="sex" value="男" ch

SQL Server 分页获取数据

select top 5000 * from ( select top 10000 *,row_number() over(order by MDMZGZD_NM,MDMZGZD_ZGBH) as rowId from ( select * from MDMZGZDMapping where F_YWXTBH IN ('XZSP') AND F_MDMNM in(select MDMZGZD_NM from MDMZGZD ) C order by rowId ) D order by rowI

页面单击按钮弹出modaldialog然后调用ajax处理程序获取数据,给父级页面控件赋值

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RefTopicList.aspx.cs" Inherits="Project.RefTopicList" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.

php高效获取数据分页

mysql.php 获取数据库中的记录,完全个人经验总结,仅供参考! <?php /** *PHP+MYSQL数据库基本功能 *http://blog.csdn.net/yown */ ############################################ #获取序列ID ############################################ function getSequence() { $sql = "update sequence set id=

Spring MVC 以.html为后缀名访问获取数据,报406 Not Acceptable错误。

如题,最近以spring mvc作为后台框架,前端异步获取数据时(.html为后缀名的访问方式),报406 Not Acceptable错误.当初都不知道啥原因,前后台都没报错就是返回不了数据,于是查了下http 406响应码:406 (SC_NOT_ACCEPTABLE)表示请求资源的MIME类型与客户端中Accept头信息中指定的类型不一致.下面请看出错的操作流程及代码: 1.先配置spring mvc 核心servlet (DispatcherServlet) 至web.xml中,其中配置