Data Bind Error One of more field types are not installed properly.
Posted: 26/07/2011 Filed under: Uncategorized | Tags: CAML, DataBinding, SPGridView Leave a comment »I was using the SPGridView control and had a particular SPListItemCollection as my data source. My data binding works fine, but I get the "One of more field types are not installed properly” error on GridViewRowDataBound event.
This was strange because I was casting the right fields and also made sure that they weren’t null. After spending considerable amount of time looking at this I found the culprit. It was my data source CAML query. Have a look at it below:
Have you found my error? If you have, then you’ve been CAMLing to much
. Well below is my updated working query:
Do you see my error now? Yup, I had used U2U’s CAML builder and then copied the query and pasted it in. Unfortunately, I had forgotten to remove the <Query></Query> elements from it. Remember, it’s not needed when you use the SPQuery object.
Hope this saves you valuable time.
SPGridView Value cannot be null. Parameter name: propName
Posted: 21/07/2011 Filed under: Uncategorized | Tags: DataBinding, SPGridView Leave a comment »Recently while helping a particularly lager business division, I noticed that a SPGridView control that they needed kept throwing the error Value cannot be null. Parameter name: propName.
Further investigation into the code behind revealed nothing out of the ordinary. A document library as the data source and such. Eventually, I had a look at the custom control itself (.ascx) and discovered that they had “Grouping” enabled.
Grouping is possible with SPGridView, see Paul Robinson’s blog post here. But they had forgotten to include and specify the GroupField and GroupDisplayName properties. Once I got this done, everything began working as how it should have in the first place.
Data Binding Error Object reference not set to an instance of an object.
Posted: 21/07/2011 Filed under: Uncategorized | Tags: DataBinding, Error, GridView Leave a comment »I got the error (as below) attempting to bind list items (SPListItemCollection) into a GridView control.
Obviously this meant that there were null objects coming through. One way to avoid this is error, is to check if the fields within the list are not null and then also handle the above mention error.
// get item object from item collection SPListItem oItem = oItemGroup[i]; // get fields from item object colSampleName = oItem["Sample Name"]; object colSampleDate = oItem["Sample Date"]; if((colSampleName != null) && (colSampleDate != null)) { // databinding operations } // handle exception
Hope this helps.