----控件组值的取得方法---

首先 Request.Form取回的一组控件的值安顺序用","隔开

如有5个相同name=name1 的text 通过 Request.Form["name"] 得到的值是字符串 1,2,3,4,5

我们用split函数把他转换为数组:Request.Form["name"].Split(','); 

然后我们就可以随意的处理了


下面通过一个简单的例子看一下:

          string[] arrid = Request.Form["id"].Split(',');//
          string[] arrfldname = Request.Form["fldname"].Split(',');
          string[] arrcaption = Request.Form["caption"].Split(',');
          string[] arrfldType = Request.Form["fldType"].Split(',');
          string[] arrmaxLength = Request.Form["maxLength"].Split(',');
          string[] arrrelateTbl = Request.Form["relateTbl"].Split(',');
          string[] arrrelateFld = Request.Form["relateFld"].Split(',');
          string[] arrbNull = Request.Form["bNull"].Split(',');
          for (int i = 0; i < arrid.Length; i++)
          {
             string id = arrid[i].ToString();
             string fldname =arrfldname[i].ToString();
             string caption = arrcaption[i].ToString();
             string fldType = arrfldType[i].ToString();
             string maxLength = arrmaxLength[i].ToString();
             string relateTbl = arrrelateTbl[i].ToString();
             string relateFld = arrrelateFld[i].ToString();
             string bNull = arrbNull[i].ToString();
            }

 

posted @ 2006-04-06 23:32  New Yang Bo Element  阅读(269)  评论(0编辑  收藏  举报