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 阅读(63) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 

常用链接

留言簿(5)

随笔分类

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜