This is a migrated thread and some comments may be shown as answers.

Binding Panel to two SQL tables.

0 Answers 40 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Everett asked on 21 Dec 2008, 04:39 PM
   I'm trying to bind a RadPanel to Two database tables.   I would like the headers to bind to a department table and expand to display a list of categories in that department.  I'm close to getting this working, but I'm ending up with one Header (with the xml root node displayed) and expanding to display departments. I think I'm off a level, but can't seem to make it work.  I tried xpath = /departments/department but it displays nodes instead of attribute( "department" instead of "department name").   Here's my code.   If there's a completely different approach, I'm willing to try it.   Thanks in advance for any help.

//From Access class, this works fine with standard treeview.



static string GetMenuItemsFromSQL()




string xml = string.Empty; 
string queryString = @"SELECT Department.Name AS name, Department.DepartmentID AS id, 
Department.Description AS desription, Category.Name AS name,



Category.CategoryID AS id

FROM Department AS department INNER JOIN

Category AS category ON department.DepartmentID = category.DepartmentID

ORDER BY department.DepartmentID

FOR XML Auto, ROOT('departments')";


string connectionString = WebSiteConfiguration.DbConnectionString; 



using (SqlConnection connection = new SqlConnection(connectionString))


SqlCommand SelectCommand = new SqlCommand(queryString, connection); 
XmlReader xr = SelectCommand.ExecuteXmlReader(); 
xml = xr.ReadOuterXml();



return xml; 

//.cs page
protected void Page_Load(object sender, EventArgs e) 


XmlDataSource1.Data =


<telerik:RadPanelBar ID="RadPanelBar1" Runat="server" Skin="Web20" ExpandMode="SingleExpandedItem"
DataSourceID="XmlDataSource1" >
<CollapseAnimation Type="None" Duration="100"></CollapseAnimation>

<telerik:RadPanelItemBinding DataMember="department" Depth="1" TextField="name" />
<telerik:RadPanelItemBinding DataMember="category" Depth="2" TextField="name" /> 






ExpandAnimation Type="None" Duration="10"></ExpandAnimation

asp:XmlDataSource ID="XmlDataSource1" runat="server" ></asp:XmlDataSource>





No answers yet. Maybe you can help?

Asked by
Top achievements
Rank 1
Share this question