我想在 C# 的 ListView 中从 Access 数据库获取数据...
这就是我正在使用的:
private void LstVwBrandNmO_SelectedIndexChanged(object sender, EventArgs e)
{
string sql = "select BrandName from Inventory";
OleDbDataAdapter da = new OleDbDataAdapter(sql, bookConn);
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
下一步做什么?
最佳答案
在获取数据表中的数据后,只需像这样分配Listiew的数据源属性 ListView.DataSource = dt
并使用databind函数将数据源绑定(bind)到列表
ListView.DataBind();
在此之前,请确保您已使用 <%#EVAL#> 定义 Itemtemplate 以绑定(bind)数据源中的值
关于c# - 在C#中的 ListView 中从access数据库获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15941104/