I'm try to fetch unique number with the other extra information that belong to the specified unique number but it "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.
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)
lblTopMerk.Text = Convert.ToString(adv.Laatstemutatie);//(this one doesn't show anything)
lblModel.Text = adv.Auto.Model; //(this is gives me the error Object reference no set to an instance of an object)