我们如何使用c#将数据网格与WPF中的数据库表绑定 [英] how can we bind datagrid with database table in WPF using c#

查看:77
本文介绍了我们如何使用c#将数据网格与WPF中的数据库表绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码将数据库表绑定到datagrid.But数据没有显示在datagrid上。我可以解决吗?





I m using following code for binding database table with datagrid.But data is not showing on datagrid.How can i solve it?


con.Open();

adap = new SqlDataAdapter("select * from details", con);
DataTable dt = new DataTable("details");

adap.Fill(dt);


dataGrid1.ItemsSource = dt.DefaultView;
con.Close();

推荐答案

在这里有一个loopk:演练:在DataGrid控件(WPF)中显示来自SQL Server数据库的数据 [ ^ ]
Have a loopk here: Walkthrough: Display Data from a SQL Server Database in a DataGrid Control (WPF)[^]


这篇关于我们如何使用c#将数据网格与WPF中的数据库表绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆