Click here to Skip to main content
15,914,642 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created an xml and have been able to call them nicely an populated them in imageButton and Labels using c#. i want to give the imageButton a PostBackUrl so that when you click on one of the imageButton, you will be redirect to another page with the information of that chosen item(ID) this is the class i used to call all the elements:

C#
<pre> public class XMLHelper
    {
        public List<CarClass> GetList()
        {
            XmlDocument xdoc = new XmlDocument();
            xdoc.Load(HttpContext.Current.Server.MapPath("~/advertenties.xml"));
            XmlNodeList AdvCars = xdoc.SelectNodes("/root/advertentie");
            var listOfAdStarCar = new List<CarClass>();
            if (AdvCars != null)
            {
                foreach (XmlNode AdvCar in AdvCars)
                {
                    var newAdStarCar = new CarClass();
                    //UnqNr

                    var unqNum = AdvCar.SelectSingleNode("unieknummer");
                    if (unqNum != null)
                    {
                        newAdStarCar.unqNr = Convert.ToInt32(unqNum.InnerText);
                    }

                    //lastMute
                    var lastMute = AdvCar.SelectSingleNode("laatstemutatie");
                    if (lastMute != null)
                    {
                        newAdStarCar.lastM = Convert.ToDateTime(lastMute.InnerText);
                    }

                    //name
                    var Dealername = AdvCar.SelectSingleNode("dealer/naam");
                    if (Dealername != null)
                    {
                        newAdStarCar.name = Dealername.InnerText;
                    }

                    //email
                    var E_mail = AdvCar.SelectSingleNode("dealer/email");
                    if (E_mail != null)
                    {
                        newAdStarCar.email = E_mail.InnerText;
                    }

                    //carNumber
                    var CarNummer = AdvCar.SelectSingleNode("auto/kenteken");
                    if (CarNummer != null)
                    {
                        newAdStarCar.CarNr = CarNummer.InnerText;
                    }

                    //company
                    var CarCompany = AdvCar.SelectSingleNode("auto/merk");
                    if (CarCompany != null)
                    {
                        newAdStarCar.CarCompany = CarCompany.InnerText;
                    }

                    //CarModel
                    var CarModel = AdvCar.SelectSingleNode("auto/model");
                    if (CarModel != null)
                    {
                        newAdStarCar.CarModel = CarModel.InnerText;
                    }

                    //BigImg
                    var FirstBigImage = AdvCar.SelectSingleNode("afbeeldingen/fotoGroot");
                    if (FirstBigImage != null)
                    {
                        newAdStarCar.BigImg = FirstBigImage.InnerText;
                    }

                    listOfAdStarCar.Add(newAdStarCar);
                }
            }
            return listOfAdStarCar;
        }



What I have tried:

I've not tried much because I just can't figure out how to do it using xml. I've done this a couple of time with database, entity framework but I'm kind a stuck with XML

I'm open for all your replies

thanks in advance
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900