如何通过.xml文件值绑定AspxMenu
XElement xml = new XElement("contacts",
from c in db.Categories
orderby c.CategoryID
select new XElement("contact",
new XAttribute("contactId", c.CategoryID),
new XElement("firstName", c.CategoryName),
new XElement("lastName", c.Description))
);
// Saving to a file, you can also save to streams
xml.Save(@"C:\contacts.xml");
<dxm:ASPxMenu ID="ASPxMenu1" runat="server">
</dxm:ASPxMenu>
使用上面的语法我可以以 XML 格式保存表值。但是我无法将此值绑定到 AspxMenu,下面的语法显示错误。
ASPxMenu1.DataSource = xml;
ASPxMenu1.DataBind();
我尝试将数据值以 xml 格式保存在特定位置,然后想将 AspxMenu 与此文件值绑定。
运行代码后,C 驱动器包含名为 contacts.xml 的文件。我想通过这个文件绑定菜单。**帮我绑定。**如何通过.xml文件值绑定AspxMenu
XElement xml = new XElement("contacts",
from c in db.Categories
orderby c.CategoryID
select new XElement("contact",
new XAttribute("contactId", c.CategoryID),
new XElement("firstName", c.CategoryName),
new XElement("lastName", c.Description))
);
// Saving to a file, you can also save to streams
xml.Save(@"C:\contacts.xml");
<dxm:ASPxMenu ID="ASPxMenu1" runat="server">
</dxm:ASPxMenu>
Using the above syntax i can save table value in XML format.But i can not bind this value to AspxMenubellow syntax show error.
ASPxMenu1.DataSource = xml;
ASPxMenu1.DataBind();
I try to save datavalue in xml format in specific location ,Then want to bind AspxMenu with this file value value.
After run the code C drive contain file named contacts.xml . I want to bind menu by this file.**Help me to bind.**HOw to bind AspxMenu by .xml file value
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们在以下视频中解释了如何将 ASPxMenu 绑定到 XMLDataSource:
http://tv.devexpress .com/#ASPxMenuBindXMLDataSource.movie
希望对您有所帮助。简而言之,您不仅应该设置 ASPxMenu 的 DataSourceID 属性,还应该将项目的 Text、Image、Url、Name 属性映射到 xml 节点中的相应属性。这可以通过设置 ASPxMenu.TextField、ASPxMenu.ImageUrlField、ASPxMenu.NavigateUrlField 和 ASPxMenu.NameField 属性来完成。您还可以在我们的文档中了解这些属性,网址为:
http://documentation.devexpress.com
We have explained how to bind an ASPxMenu to an XMLDataSource in the following video:
http://tv.devexpress.com/#ASPxMenuBindXMLDataSource.movie
I hope, it will be helpful to you. In short, you should not only set the ASPxMenu's DataSourceID property, but also map item's Text, Image, Url, Name properties to the corresponding attributes in an xml node. This can be done by setting the ASPxMenu.TextField, ASPxMenu.ImageUrlField, ASPxMenu.NavigateUrlField and ASPxMenu.NameField properties. You can also read about these properties in our documentation available at:
http://documentation.devexpress.com