listview 无法绑定 数据无法显示
代码:
private void test_Load(object sender, EventArgs e) //放到窗体load事件
{
Open();
string sql = "select * from tyq_jldxx";
try
{
OdbcCommand cmd = new OdbcCommand(sql, con);
OdbcDataReader dr = cmd.ExecuteReader();
listView1.View = View.Details;
listView1.FullRowSelect = true;
while (dr.Read())
{
ListViewItem lv = new ListViewItem();
lv.SubItems[0].Text = dr["name_jld"].ToString();
lv.SubItems.Add(dr["name_cz"].ToString());
listView1.Items.Add(lv);
}
dr.Close();
}
运行后listview没显示任何数据,请高手帮忙,谢谢!