2009-08-22 45 views
0

是否有可能有一个从xml文件动态生成的gridview复选框?从gridview中选择

这里的LINQ查询我使用的查询XML:

VAR酒店从酒店=在xmlDoc.Descendants( “表”) 其中hotel.Element( “HOTEL_AREA”)值== ddllocation。 .SelectedItem.ToString() & & Double.Parse(pplTextBox.Text)< = Double.Parse(hotel.Element( “NO_OF_PEOPLE”)。值) 选择新 { 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 }; 和gridview。提前致谢。

GridView1.DataSource = hotels.ToList(); 

    GridView1.DataBind(); 

回答

0

您可以将gridview设置为不自动生成列。然后你可以用你想要的额外列设置你的列。

当您为列表中的项目设置列时,列名称必须与代码和设计器中的内容匹配。

你也可以做到这一切的代码,下面是一个例子: adding columns programmatically to gridview