Hi
We are trying to hook a toolbar through to an XML file that we are also using for Context Menus on a Rad Tree View as well.
To do this, we cant use the LoadContentFile method because the XML structure we are using is not the same as the expected structure for this control. Instead, we are populating an XML Data Source with the XML and then binding the Toolbar to the Data Source.
When we trying to evaluate e.Button.DataItem in the ButtonDataBound event, .Net is reporting that the dataItem type is a System.Web.UI.WebControls.XmlDataSourceNodeDescriptor.
I've seen elsewhere in the forums that someone had a similar problem when trying to use LoadContentFile here but im wondering if this is a different spin on the same problem?
For your information, we are currently using Q1 2009 Bulid 527
Below is a cut down sample of what we are trying to do:
XML File
Populate Toolbar
Button Data Bound Event
I hope I haven't missed something obvious!
We are trying to hook a toolbar through to an XML file that we are also using for Context Menus on a Rad Tree View as well.
To do this, we cant use the LoadContentFile method because the XML structure we are using is not the same as the expected structure for this control. Instead, we are populating an XML Data Source with the XML and then binding the Toolbar to the Data Source.
When we trying to evaluate e.Button.DataItem in the ButtonDataBound event, .Net is reporting that the dataItem type is a System.Web.UI.WebControls.XmlDataSourceNodeDescriptor.
I've seen elsewhere in the forums that someone had a similar problem when trying to use LoadContentFile here but im wondering if this is a different spin on the same problem?
For your information, we are currently using Q1 2009 Bulid 527
Below is a cut down sample of what we are trying to do:
XML File
<?xml version="1.0" encoding="utf-8" ?> |
<Menu> |
<Reports> |
<Item Value="Preview" Text="Preview" ImageName="Preview" /> |
<Item Value="Print" Text="Print" ImageName="Print" /> |
<Item Value="Export" Text="Export" ImageName="Export"> |
<Item Value="ExportCSV" Text="CSV Format" ImageName="Export" /> |
<Item Value="ExportPDF" Text="PDF Format" ImageName="Export" /> |
</Item> |
</Reports> |
</Menu> |
Populate Toolbar
Public Shared Function GetToolbar(ByVal Type As MenuType) As RadToolBar |
Dim FilePath As String = "~/App_Data/Menus.xml" |
Dim xPath As String = "/Menu/Reports/Item" |
Dim xmlMenu As New XmlDataSource |
With xmlMenu |
.DataFile = FilePath |
.XPath = xPath |
.DataBind() |
End With |
tlb = New RadToolBar |
With tlb |
.DataSource = xmlMenu |
.DataBind() |
End With |
Return tlb |
End Function |
Button Data Bound Event
Private Shared Sub tlb_ButtonDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarButtonEventArgs) Handles tlb.ButtonDataBound |
With e.Button |
Dim element As XmlElement = DirectCast(.DataItem, XmlElement) |
If element.HasAttribute("Value") Then .Value = element.Attributes("Value").Value |
If element.HasAttribute("Text") Then .Text = element.Attributes("Text").Value |
If element.HasAttribute("ImageName") Then .ImageUrl = GetImageURL(element.Attributes("ImageName").Value) |
End With |
End Sub |
I hope I haven't missed something obvious!