datagridview绑定数据源之后显示不出数据...
RT.
初学者.
三层架构模式下写了个程序.
这是我的表示层代码:
EmployeeManager epm = new EmployeeManager();
private void button1_Click(object sender, EventArgs e)
{
this.dataGridView1.DataSource = epm.GetAll();
}
private void EmployeeInformation_Load(object sender, EventArgs e)
{
this.dataGridView1.AutoGenerateColumns = false;
this.dataGridView1.DataSource = epm.GetAll();
}
业务层
public List<Employee> GetAll()
{
return es.GetAll();
}
访问层
public List<Employee> GetAll()
{
List<Employee> list = new List<Employee>();
string sql = "select * from employee";
DataTable dt = DBHelper.GetDataTable(sql);
foreach (DataRow dr in dt.Rows)
{
Employee emp = new Employee();
emp.Eid = Convert.ToInt32(dr[0]);
emp.Ename = Convert.ToString(dr[1]);
emp.Eidentitycard=Convert.ToString(dr[2]);
emp.Ebirthday = Convert.ToString(dr[3]);
emp.Emale = Convert.ToString(dr[4]);
emp.Edegree = Convert.ToString(dr[5]);
emp.Eemail = Convert.ToString(dr[6]);
emp.Ephone = Convert.ToString(dr[7]);
emp.Edepartment = Convert.ToString(dr[8]);
emp.Eposition = Convert.ToString(dr[9]);
emp.Esalarygrade = Convert.ToString(dr[10]);
emp.Enote = Convert.ToString(dr[11]);
emp.Eentrydate = Convert.ToString(dr[12]);
list.Add(emp);
}
return list;
}
模型层就是设置了些属性.
编译的时候没有错误. 就是运行的时候dgv不显示数据...
希望有高手帮忙解决一下.谢谢
------解决方案--------------------
你要不先不要经过BLL,直接绑定DAL里面的DataTable,看看有没有数据,如果还是没有,就是DbHelper问题了,最后的回复,明天见