views:

33

answers:

1

Is it possible to have checkboxes with a gridview that is dynamically generated from an xml file?

Here's the LINQ query that I am using to query the xml:

var hotels = from hotel in xmlDoc.Descendants("Table") where hotel.Element("HOTEL_AREA").Value == ddllocation.SelectedItem.ToString() && Double.Parse(pplTextBox.Text) <= Double.Parse(hotel.Element("NO_OF_PEOPLE").Value) select new { RoomCost = hotel.Element("ROOM_COST").Value, RoomType = hotel.Element("ROOM_TYPE").Value, HotelName = hotel.Element("HOTEL_NAME").Value, NoOfPeople = hotel.Element("NO_OF_PEOPLE").Value, Smoking = hotel.Element("SMOKING").Value, Restaurant = hotel.Element("RESTAURANT").Value }; and the gridview. Thanks in advance.

    GridView1.DataSource = hotels.ToList();

    GridView1.DataBind();
A: 

You could set the gridview to not auto generate columns. Then you would setup your columns with the extra column you want.

When you setup the columns for the items in the list the column names must match between the code and what you have in the designer.

You can also do it all in code, below is a sample: adding columns programmatically to gridview

klabranche