请问各种,list<>怎样像 下面dataset 那样迭代显示数据呢?           DataSet ds = bll.GetList();
           if (ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = ds.Tables[0].Rows[i];
                   dr["Title"].ToString() 
                }
            }用list 的话,下面操作,好像只能显示一行数据。            List<Entity.news> list = bll.LoadAll();
           if (list.Count > 0)
           {
               foreach (Entity.news model in list)
               {
                   model.title.tostring();
               }
           }
怎么写才能读出全部多行数据呢

解决方案 »

  1.   

    应该是可以的 ,没问题,估计是你的list就一条记录。List<Entity.news> list = bll.LoadAll();
    Response.Write("记录条数为:"+list.Count);
    if (list.Count > 0)
    {
       foreach (Entity.news model in list)
       {
            Response.Write(model.title.ToString());
       }
    }
      

  2.   

    或者检查bll.LoadAll()的内部实现
      

  3.   

    写法是没有问题的,LZ设断点跟进去看一下,bll.LoadAll()调出来了几条数据,count是几