码迷,mamicode.com
首页 > 其他好文 > 详细

DataSet转换成List<>

时间:2018-01-08 21:07:04      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:row   bool   rtt   i++   for   contents   color   ted   UI   

DataSet ds = adao.GetList(0, "recommend=‘true‘", "");

            List<ArticleInfo> list = new List<ArticleInfo>();
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                ArticleInfo model = new ArticleInfo();
                model.arttime = Convert.ToDateTime(ds.Tables[0].Rows[i]["arttime"]);
                model.cgyid = Convert.ToInt32(ds.Tables[0].Rows[i]["cgyid"]);
                model.clicks = Convert.ToInt32(ds.Tables[0].Rows[i]["cgyid"]);
                model.contents = Convert.ToString(ds.Tables[0].Rows[i]["cgyid"]);
                model.id = Convert.ToInt32(ds.Tables[0].Rows[i]["cgyid"]);
                model.img = Convert.ToString(ds.Tables[0].Rows[i]["cgyid"]);
                model.recommend = Convert.ToBoolean(ds.Tables[0].Rows[i]["cgyid"]);
                model.related = Convert.ToBoolean(ds.Tables[0].Rows[i]["cgyid"]);
                model.title = Convert.ToString(ds.Tables[0].Rows[i]["cgyid"]);
                model.uid = Convert.ToInt32(ds.Tables[0].Rows[i]["cgyid"]);
                list.Add(model);
            }
            ViewBag.list = list;

 

DataSet转换成List<>

标签:row   bool   rtt   i++   for   contents   color   ted   UI   

原文地址:https://www.cnblogs.com/yangwang365/p/8244707.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!