ASP.NET 如何接收GET数组表单数据

来源:百度知道 编辑:UC知道 时间:2024/06/05 17:46:57
GET的字符串如下
?id[1]=2&id[3]=4&id[9]=1
我想通过这个方式批量修改表数据
请问有没有好的算法或方法。
谢谢。
括号里的数据是未知的。
我现在没有好的方法。在PHP在这个传值会被认为数组。
但是在.NET里不行。
在。NET里我是这样处理的。
Dim _Value As Integer
Dim _Id As Integer
For i As Integer = 0 To Request.Form.Count - 1
If Request.Form.GetKey(i).ToLower.IndexOf("id[".ToLower) = 0 Then
'得到ID号
_Id=Request.Form.GetKey(i).ToString.ToLower.Replace("id[", "").Replace("]", ""),
'得到值
_Value=Request.Form(i).ToString
End If
Next

Request.QueryString["id[1]"]
Request.QueryString["id[3]"]
Request.QueryString["id[9]"]

for (int i = 0; i < Request.QueryString.AllKeys.Length; i++)
{
Request.QueryString[i].ToString();
}

最好用字符串连接.然后在后台分割字符串,例如:?ids="2,4,1"
string ids=request.QueryString["ids"];
string[] ids_array=ids.Split(",");

request["id[3]"]
这种是通用的无论GET或POST都可以

546877866