因为 Request.From 接收到的可能是一个数组
而.net 里面不知道怎么写?用“,”分割??但是这样如果表单的值中,那就错乱了
asp 里面有这样的用法:
Request.Form(element)[(index)|.Count]
int ClassID;
string classId = Request.Form["ClassID"] as string;
if (int.TryParse(classId, out ClassID))
{
if (ClassID>0)
{
string[] Titles = Request.Form.GetValues("Title");
string[] Urls = Request.Form.GetValues("Url");
if (Titles.Length == Urls.Length)
{
for (int i = 0; i < Titles.Length; i++)
{
SqlParameter[] sps ={
new SqlParameter("@Title",Titles[i]),
new SqlParameter("@Url",Urls[i]),
new SqlParameter("@ClassID",ClassID)
};
DB.Db.Instance.runSql("insert into [Links](Title,Url,ClassID) values(@Title,@Url,@ClassID)", sps);
}
}
}
}