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)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 永福县| 子洲县| 全州县| 元氏县| 屏山县| 临清市| 景谷| 抚州市| 延安市| 穆棱市| 广东省| 谢通门县| 页游| 诸城市| 蓬溪县| 稻城县| 修文县| 湖南省| 会泽县| 沾化县| 阿尔山市| 汾阳市| 华亭县| 贺兰县| 揭西县| 万安县| 阿克| 峡江县| 昭苏县| 望江县| 琼中| 建瓯市| 邮箱| 高淳县| 新丰县| 岗巴县| 望都县| 鲁山县| 淅川县| 蓬溪县| 庄浪县|