tailieunhanh - ASP.NET 4 Unleased - p 107

Việc kiểm soát Menu bao gồm một phần tử . Nguyên tố này bao gồm hai subtags MenuItemBinding. Các subtag đầu tiên đại diện cho mối quan hệ giữa các nút thể loại trong tập tin XML và | 1034 CHAPTER 22 Using the Navigation Controls LISTING @ Page Language C DOCTYPE html PUBLIC - W3C DTD XHTML EN http TR xhtml11 DTD html xmlns http 1999 xhtml head id Head1 runat server title Menu XML Complex title head body form id form1 runat server div asp Menu id Menu1 DataSourceID srcMenu Runat server DataBindings asp MenuItemBinding DataMember category TextField text asp MenuItemBinding DataMember item TextField text ValueField price DataBindings asp Menu asp XmlDataSource id srcMenu DataFile Runat server div form body html The Menu control includes a DataBindings element. This element includes two MenultemBinding subtags. The first subtag represents the relationship between the category nodes in the XML file and the menu items. The second subtag represents the relationship between the item nodes in the XML file and the menu items. From the Library of Wow eBook Using the Menu Control 1035 Binding to Database Data You can t bind a Menu control directly to database data. Neither the SqlDataSource nor ObjectDataSource controls implement the IHierachicalDataSource interface. Therefore if you want to represent database data with the Menu control you need to perform some more work. One option is to create your own SqlHiearachicalDataSource control. You can do this either by deriving from the base HiearchicalDataSourceControl class or implementing the IHiearchicalDataSource interface. You take this approach in the final section of this chapter when a custom SqlHierarchicalDataSource control is built. A second option is to build the menu items programmatically in the Menu control. This is the approach followed here. Imagine that you want to represent the contents of the following database table with a Menu control 22 Categoryld ParentId Name 1 null Beverages 2 null Fruit 3 1 Milk 4 1 Juice 5 4 Apple Juice 6 4 Orange Juice 7 2 Apples 8 2 Pears This database table represents product .