Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 在MVC3中发布表单_Asp.net Mvc 3 - Fatal编程技术网

Asp.net mvc 3 在MVC3中发布表单

Asp.net mvc 3 在MVC3中发布表单,asp.net-mvc-3,Asp.net Mvc 3,我有一个从多个局部视图加载数据的页面。其中一个局部视图几乎没有链接。说3。每次用户点击链接时,我都会用与点击链接相关的数据重新加载页面。表单看起来像这样 @model TestPostback.Models.HomeModel @{ ViewBag.Title = "Index"; } <h2>Index</h2> <form id="testform" method="post" action="@Url.Action("Index","Home")"

我有一个从多个局部视图加载数据的页面。其中一个局部视图几乎没有链接。说3。每次用户点击链接时,我都会用与点击链接相关的数据重新加载页面。表单看起来像这样

@model TestPostback.Models.HomeModel
@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<form id="testform" method="post" action="@Url.Action("Index","Home")" runat="server">
    <div>
        <table>
            <tr>
                <td>                    
                        <a href="@Url.Content("/Home/Index?selectedValue=Personal")"> This is a test page </a>
                </td>
            </tr>            
        </table>
    </div>
</form>

<div>
    <table>
        <tr>
            <td style="vertical-align:top;">                                        
                <h2 class="expand">Test Expand</h2>
                <div class="collapse">
                    <table id="testgrid" class="scroll" cellpadding="0" cellspacing="0"></table>
                </div>
            </td>
        </tr>
    </table>
</div>


<script type="text/javascript">    

    jQuery(document).ready(function () {
        var grid = jQuery("#testgrid");        
        grid.jqGrid({
            url: 'Home/GridData/',
            datatype: 'json',
            mtype: 'POST',
            colNames: ['Id', 'Votes', 'Title'],
            colModel: [
                        { name: 'Id', index: 'Id', width: 40, align: 'left' },
                        { name: 'Votes', index: 'Votes', width: 40, align: 'left' },
                        { name: 'Title', index: 'Title', width: 400, align: 'left'}
                    ],
            rowNum: 10,
            rowList: [5, 10, 20, 50],
            sortname: 'Id',
            sortorder: "desc",
            viewrecords: true,
            imgpath: '',
            caption: 'My first grid'
        });        
    });    
</script>
这就是我要做的。 当我点击链接“这是一个测试页面”时,它会用一些值调用控制器,但不会加载我的网格。我想要这个值,因为我想根据用户的点击加载一个具有不同值的网格。我要做什么样的改变才能让它工作


请给出建议。

我建议如下:因此,在发布后,您将重定向到任何适合的操作方法(在本例中,是显示所有jqGrids的方法)。使用MVC可以实现这一点,或者使用
控制器上可用的
重定向到操作
方法

在取回数据时是否序列化数据(即serializeGridData)

您是通过JSON加载的吗

如果是,请查看

这不起作用,因为我必须从数据库中加载一些其他包含数据/文本的局部视图。所以我想做的是返回一个视图,加载部分视图中的所有数据,然后调用那些加载网格数据的控制器方法?这里的代码没有显示,因为这里只有一个表单,没有显示网格,所以我不得不这么想?更多详情请:)我已经更新了问题。请给我一些建议。谢谢我已经更新了我的问题。你能回顾一下吗?让我知道我该怎么做才能让它发挥作用?
 public ActionResult Index(string selectedValue)
        {
            return View();
        }

        public JsonResult GridData(string sidx, string sord, int page, int rows)
        {
            int totalPages = 1; // we'll implement later
            int pageSize = rows;
            int totalRecords = 3; // implement later

            var jsonData = new
            {
                total = totalPages,
                page = page,
                records = totalRecords,
                rows = new[]{
                    new {id = 1, cell = new[] {"1", "-7", "Is this a good question?"}},
                    new {id = 2, cell = new[] {"2", "15", "Is this a blatant ripoff?"}},
                    new {id = 3, cell = new[] {"3", "23", "Why is the sky blue?"}}
                }
            };
            return Json(jsonData);
        }