如何将数组从视图传递到控制器 [英] how to pass an array from view to controller
本文介绍了如何将数组从视图传递到控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我看来,我创建了一个二维数组,并将该值分配给一个变量.现在我想将该数组用作控制器中方法的参数.如何将该数组传递给控制器. br/>
查看代码是:
in my view i created a two dimensional array.and i assigned that value to one variable.now i want to use that array as a parameter to a method in the controller.how can i pass that array to the controller.
view code is:
var gridArray = new Array(g_rows);
for (var i = 1; i < g_rows; i++) {
gridArray[i] = new Array(g_colums);
for (var j = 1; j < g_colums; j++) {
var val = mygrid.cells(i,j).getValue();
gridArray[i][j] = val;
推荐答案
您应该使用视图模型".基本上,仅为视图创建模型",其中包含视图中所需的数据项.这是使数据进出视图的好方法.
您可以在中引用该链接. http://stephenwalther.com/blog/archive/2009/04/13/asp-net-mvc-tip-50-ndash-create-view-models.aspx [
You should look at using a "view model". You basically create "Models" just for your view that contain the data items you need in your view. It is a great way of getting data in and out of your view.
You can refer the link at http://stephenwalther.com/blog/archive/2009/04/13/asp-net-mvc-tip-50-ndash-create-view-models.aspx[^]
这篇关于如何将数组从视图传递到控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文