0

I'm trying to fetch unique number with the other extra information that belong to the specified unique number but it gives me this error"Object reference not set to an instance of an object.". I have created this class and when i run, it only fetches the unique and display it well but it does not fetch the other values that belongs to the unique number. I've searched for many examples but i just can't fine anyone that help to fix this one.

this is my .cs

public Advertentie GetDetails(string unieknummer)
    {
        XmlRootAttribute xRoot = new XmlRootAttribute();
        xRoot.ElementName = "root";
        xRoot.IsNullable = true;

        XmlSerializer deserializer = new XmlSerializer(typeof(Advertentie), xRoot);
        StreamReader reader = new StreamReader("C:\\Users\\Gabriel\\documents\\visual studio 2013\\Projects\\ADadvertisement\\ADadvertisement\\Xml\\advertenties.xml");
        Advertentie rootObj = (Advertentie)deserializer.Deserialize(reader);
        rootObj.Unieknummer = unieknummer;
        return rootObj;
    }

and in my Page_load()

var obj = new XMLHelper();
        Advertentie adv = obj.GetDetails(Request.QueryString["unieknummer"]);


        lblTopModel.Text = adv.Unieknummer; //(this one works fine, it show the unique number)
        lblTopMerk.Text = Convert.ToString(adv.Laatstemutatie);//(this one doesn't show anything)
        lblModel.Text = adv.Auto.Model; //(this one gives me the error Object reference no set to an instance of an object)
T Gabe
  • 15
  • 7

0 Answers0