I am binding an SPGridView to a SPList. As code samples suggest, I am using the following code to create a dataview based on the list.
dim data as DataView = myList.Items.GetDataTable.DefaultView grid.DataSource = data etc...
What I am finding is that the column names in the resulting dataview do not always match the source fields defined in the SPList. For example I have columns named
- Description
- ReportItem
-
ReportStatus
these show up in the resulting dataview with column names like
- ReportType0
- ReportStatus1
This leads me to think that I have duplicate field names defined, but that does not seem to be the case.
Seems like I am missing something fundamental here? Thanks.
The
GetDataTablemethod is returning theinternalName(orstaticName— I can’t remember for sure which but they are frequently the same) representation of the columns, rather than theTitlerepresentation, which is what you see in the Web interface. I believeGetDataTabledoes a CAML query under the covers, and you have to use thatinternalNamefor field references in CAML.This blog talks about it in a little more detail.