将ILIST绑定到DataGridView时出现奇怪错误 [英] Strange error in binding ILIST to DataGridView

查看:127
本文介绍了将ILIST绑定到DataGridView时出现奇怪错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个给我发送JSON结果的webapi。此结果映射到对象列表(Employee)。

在我的ASP.NET GridView中,我这样做:



Hi all,

I have a webapi which sends me a JSON result. This result is mapped to a list of objects (Employee).
In my ASP.NET GridView I do:

werknemer = new DataCollector.WerknemerRepository();

                grdPersoneel.DataSource = werknemer.Get();
                grdPersoneel.DataBind();





(翻译:werknemer =员工.Personeel =员工)



但是在grdPersoneel.DataBind();我收到消息:



(translation: werknemer = employee. Personeel = employees)

But on grdPersoneel.DataBind(); I get the message:

The data source for the GridView with id grdPersoneel had no features or details that columns could be generated. Make sure the data source has content.





grdPersoneel.DataSource声明拥有241个可用行,只需要列出List<>在werknemer.Get()的结果中。为什么它没有数据绑定以及如何获取数据绑定?



The grdPersoneel.DataSource claims is has the 241 available rows, just likt the List<> in the result of werknemer.Get(). Why it does not databind and how to get the data bind?

推荐答案

嗯......非常简单。

如果你不这样做使用get;组;在你的属性上,gridView不知道要绑定什么。
Well... pretty simple.
If you don't use get; set; on your properties the gridView does not know what to bind.


这篇关于将ILIST绑定到DataGridView时出现奇怪错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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