开发者

SPList.GetItems defaultView returning different fields than are actually present in the DefaultView of the list

I am binding the SPList Items to the GridView by getting a DataTable, but I am getting entirely different fields in the DataTable from the fields which are present in the DefaultView of the SPList.

Not the field names开发者_StackOverflow中文版 changed (internal names/ title) , but the fields itself are different ones than are present in the list's default view.

I am using the following code:

GridView gd = new GridView();

            gd.DataSource = list.GetItems(list.DefaultView).GetDataTable();


This is most likely due to the list.DefaultView either not being populated or correct. Try setting the value before you call get items. i.e..

SPView defView = list.DefaultView;
gd.DataSource = list.GetItems(list.DefaultView).GetDataTable();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜