把生活写成首诗
2020-04-01 10:21
采纳率: 100%
浏览 609

C#中DataGridView怎么显示List集合中个别数据

   public List<teache> getteacherdata()
       {
           List<teache> te = new List<teache>();
           string sql = "select * from teacher";
           var reader = SqlDBHelper.ExecuteReader(sql);
           while (reader.Read())
           {
               teache tea = new teache();
               tea.Logid = Convert.ToInt32(reader["username"]); ;
               tea.Logpwd = Convert.ToInt32(reader["password"]);
               tea.Name = Convert.ToString(reader["name"]);
               tea.Gender = Convert.ToString(reader["gender"]);
               tea.Faculty = Convert.ToString(reader["faculty"]);
               tea.Phone = Convert.ToInt32(reader["telephone"]);
               tea.Title = Convert.ToString(reader["title"]);
               tea.Direction = Convert.ToString(reader["direction"]);
               tea.Digest = Convert.ToString(reader["digest"]);


               te.Add(tea);
           }
           return te;
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题