Skip to main content

Microsoft Silverlight

Answered Question Error - object reference not set to an instance of an objectRSS Feed

(0)

bhat555
bhat555

Member

Member

0 points

1 Posts

Error - object reference not set to an instance of an object

Hi

I am getting error 'object reference not set to an instance of an object' when using following code to retrieve data from SharePoint list  

Xnamespace ns = "#RowsetSchema"; 

var query = from x in e.Result.Descendants()

where x.Name == ns + "row"

select x.Attribute("ows_BrandName").Value;

 but when I am using following code i.e without 'Value' it works & display ows_BrandName = 'Pepsodent'

Xnamespace ns = "#RowsetSchema"; 

var query = from x in e.Result.Descendants()

where x.Name == ns + "row"

select x.Attribute("ows_BrandName");

 

Can someone tell me what's wronge with the first code block? How to get ony value  part ?

 

Thanks

Brennca3344
Brennca3344

Member

Member

28 points

5 Posts

Answered Question

Re: Error - object reference not set to an instance of an object

Perhaps try setting a properly typed variable = x.Attribute("ows_BrandName"), and then try "select variable.Value", something like this (I'm not sure what type x is):

var result = x.Attribute("ows_BrandName")

select result.Value;

 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities