public string getTableData(DataTable dt,string Model, params string[] columns)
                  {

                      System.Text.StringBuilder tempSb = new System.Text.StringBuilder("");
                      if(dt!=null)
                      {
                          foreach (DataRow dr in dt.Rows)
                          {
                              string[] tempStr = new string[columns.Length];
                              for (int i = 0; i < tempStr.Length; i++)
                              {
                                  tempStr[i] = Convert.ToString(dr[columns[i]]);
                              }

                              tempSb.AppendFormat(Model, tempStr);
                          }
                      }
                      return tempSb.ToString();
                     
                  }

             string tempCitySql = "select CityId,City from city where father='330000'";

            string tempCityModel = "<option value=\"{0}\">{1}</option>";

           this.tempCityData = getTableData(ds.Tables[0], tempCityModel, "City", "City");

           

           

           

          一個值得借鑒的數據綁定函數


          文章來源:http://www.cnblogs.com/wangdetian168/archive/2008/10/10/1307999.html
          posted on 2010-09-30 12:23 sanmao 閱讀(81) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 郸城县| 高雄市| 阿坝| 左权县| 穆棱市| 错那县| 庆城县| 盐津县| 化州市| 将乐县| 扎鲁特旗| 乾安县| 伊宁市| 仙桃市| 安吉县| 沙雅县| 淮北市| 开阳县| 抚松县| 正定县| 永州市| 岳池县| 华池县| 白水县| 喀什市| 普兰县| 措美县| 微博| 手游| 湖南省| 淮南市| 馆陶县| 曲水县| 潮安县| 青铜峡市| 尼玛县| 东乌珠穆沁旗| 新竹县| 卢湾区| 梁河县| 华安县|