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 閱讀(80) 評論(0)  編輯  收藏

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


          網站導航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 台山市| 金华市| 汶上县| 阿城市| 措勤县| 新巴尔虎右旗| 德保县| 双峰县| 合肥市| 讷河市| 崇仁县| 定安县| 云安县| 皋兰县| 乌拉特后旗| 枣阳市| 疏附县| 房山区| 顺平县| 安宁市| 儋州市| 古蔺县| 营山县| 姚安县| 郓城县| 水富县| 罗甸县| 梓潼县| 霍林郭勒市| 巴彦淖尔市| 育儿| 高青县| 望都县| 浪卡子县| 浠水县| 徐水县| 武穴市| 腾冲县| 翁牛特旗| 台北市| 建平县|