ASPxNavBar.GroupDataFields Property
Provides access to properties allowing you to specify data fields (attributes of xml elements) from which group settings of a bound NavBar should be obtained.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v19.2.dll
Declaration
public NavBarGroupDataFields GroupDataFields { get; }
Public ReadOnly Property GroupDataFields As NavBarGroupDataFields
Property Value
Example
When the ASPxNavBar is bound to XmlDataSource, the latter should suit the following structure:
<Root>
<Group Text ="Reports">
<Item Text =" ... " NavigateUrl="..." ImageUrl="..." />
</Group>
</Root>
In this case, XmlDataSource can retrieve and synchronize the Text, NavigateUrl and ImageUrl XML attributes with ASPxNavBar properties. However, in real applications, data seldom suits this structure. Most often, an XML schema contains several sub- nodes that describe some element. For instance:
<Menus>
<Menu text="abc1">
<ProductID>193</ProductID>
<ProductName>090 - Introduction</ProductName>
<PTName>Video</PTName>
</Menu>
</Menus>
XmlDataSource cannot parse such a schema. However, XmlDataSource allows specifying an XSLT file where you can define a transformation that will be applied to the specified DataFile. In this case, it is necessary to utilize the GroupContentTemplate. For example:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<Menus>
<xsl:for-each select="//Menus/*">
<Menu Text="{ProductName}" ProductID="{ProductID}">
</Menu>
</xsl:for-each>
</Menus>
</xsl:template>
</xsl:stylesheet>
<GroupContentTemplate>
ProductID:
<asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container.Group.DataItem, "ProductID") %>'></asp:Label>
</GroupContentTemplate>
You can learn more about XML transformation files from the following sources:
Using XSLT files with the new XMLDataSource control
XSLT - Transformation
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<Menus>
<xsl:for-each select="//Menus/*">
<Menu Text="{ProductName}" ProductID="{ProductID}" DateAdded="{DateAdded}" PCName="{PCName}">
</Menu>
</xsl:for-each>
</Menus>
</xsl:template>
</xsl:stylesheet>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxNavBar" TagPrefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/Lessons.xml"
XPath="//Menus/*" TransformFile="~/App_Data/Lessons.xsl"></asp:XmlDataSource>
<dx:ASPxNavBar ID="ASPxNavBar1" runat="server" ClientIDMode="AutoID" DataSourceID="XmlDataSource1">
<GroupContentTemplate>
ProductID:
<asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container.Group.DataItem, "ProductID") %>'></asp:Label><br />
DateAdded:
<asp:Label ID="Label2" runat="server" Text='<%# DataBinder.Eval(Container.Group.DataItem, "DateAdded") %>'></asp:Label><br />
PCName:
<asp:Label ID="Label3" runat="server" Text='<%# DataBinder.Eval(Container.Group.DataItem, "PCName") %>'></asp:Label><br />
</GroupContentTemplate>
<GroupDataFields TextField="Text" />
</dx:ASPxNavBar>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
<Menus>
<Menu text="abc1">
<ProductID>193</ProductID>
<PLID>3</PLID>
<ProductName>090 - Introduction</ProductName>
<Description />
<DateAdded>2010-07-05T00:00:00-04:00</DateAdded>
<Scheduled>No</Scheduled>
<PTName>Video</PTName>
<PDName>On-Demand</PDName>
<PLName>lvl 1</PLName>
<LevelNumber>1</LevelNumber>
<PCName>Education</PCName>
</Menu>
<Menu text="abc2">
<ProductID>200</ProductID>
<PLID>3</PLID>
<ProductName>101 - Introduction to Investment Income</ProductName>
<Description />
<DateAdded>2010-07-21T00:00:00-04:00</DateAdded>
<Scheduled>No</Scheduled>
<PTName>Video</PTName>
<PDName>On-Demand</PDName>
<PLName>lvl 1</PLName>
<LevelNumber>1</LevelNumber>
<PCName>Education</PCName>
</Menu>
</Menus>
<Menus>
<Menu text="abc1">
<ProductID>193</ProductID>
<PLID>3</PLID>
<ProductName>090 - Introduction</ProductName>
<Description />
<DateAdded>2010-07-05T00:00:00-04:00</DateAdded>
<Scheduled>No</Scheduled>
<PTName>Video</PTName>
<PDName>On-Demand</PDName>
<PLName>lvl 1</PLName>
<LevelNumber>1</LevelNumber>
<PCName>Education</PCName>
</Menu>
<Menu text="abc2">
<ProductID>200</ProductID>
<PLID>3</PLID>
<ProductName>101 - Introduction to Investment Income</ProductName>
<Description />
<DateAdded>2010-07-21T00:00:00-04:00</DateAdded>
<Scheduled>No</Scheduled>
<PTName>Video</PTName>
<PDName>On-Demand</PDName>
<PLName>lvl 1</PLName>
<LevelNumber>1</LevelNumber>
<PCName>Education</PCName>
</Menu>
</Menus>
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxNavBar" TagPrefix="dx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/Lessons.xml"
XPath="//Menus/*" TransformFile="~/App_Data/Lessons.xsl"></asp:XmlDataSource>
<dx:ASPxNavBar ID="ASPxNavBar1" runat="server" ClientIDMode="AutoID" DataSourceID="XmlDataSource1">
<GroupContentTemplate>
ProductID:
<asp:Label ID="Label1" runat="server" Text='<%#DataBinder.Eval(Container.Group.DataItem, "ProductID")%>'></asp:Label><br />
DateAdded:
<asp:Label ID="Label2" runat="server" Text='<%#DataBinder.Eval(Container.Group.DataItem, "DateAdded")%>'></asp:Label><br />
PCName:
<asp:Label ID="Label3" runat="server" Text='<%#DataBinder.Eval(Container.Group.DataItem, "PCName")%>'></asp:Label><br />
</GroupContentTemplate>
<GroupDataFields TextField="Text" />
</dx:ASPxNavBar>
</div>
</form>
</body>
</html>
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
End Class
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<Menus>
<xsl:for-each select="//Menus/*">
<Menu Text="{ProductName}" ProductID="{ProductID}" DateAdded="{DateAdded}" PCName="{PCName}">
</Menu>
</xsl:for-each>
</Menus>
</xsl:template>
</xsl:stylesheet>
See Also