日期:2014-05-20  浏览次数:21061 次

Single出来的数据为什么在dataGridView 不显示?
C# code
  var v = dc.baobao.Single(q => q.huohao=="1361");

    dataGridView1.DataSource = v;


调试的时候看到v已经有baobao完整表.但是dataGridView1不显示.
要怎么做才显示呢?


------解决方案--------------------
你把它转换成一个datatable看看
------解决方案--------------------
var v = dc.baobao.Single(q => q.huohao=="1361");
DataTable dt=v;
dataGridView1.DataSource = dt;

因为dataGridView的数据源和表是能对应的,而你的var格式使得dataGridView1对应不了字段和值
------解决方案--------------------
public Object DataSource { get; set; }

The IList interface, including one-dimensional arrays.

The IListSource interface, such as the DataTable and DataSet classes.

The IBindingList interface, such as the BindingList<T> class.

The IBindingListView interface, such as the BindingSource class.

Single返回的是一个实体