将数组发送到控制器。 [英] Send an array to controller.

查看:93
本文介绍了将数组发送到控制器。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的代码视图:



I have such a code view:

@foreach(var request in request_list)
{
<input name="abc[@requst.id]" value="1">
}





如何发送控制器?

我尝试:





How to Send controller?
I try to:

[httpPost]

public ActionResult Edit(string[] abc)





但它不起作用。

我可以尝试什么?

谢谢!



But it does not work.
What can I try?
Thank you!

推荐答案

你需要使用for循环并使用索引器(listData [i])引用数组而不是使用foreach循环。这里有一个例子



c# - 用于列表项的Asp.net razor文本框数组 - Stack Overflow [ ^ ]
You need to use a for loop and reference the array using an indexor (listData[i]) rather than using a foreach loop. There is an example here

c# - Asp.net razor textbox array for list items - Stack Overflow[^]


这篇关于将数组发送到控制器。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆