Hello
I get this Exception when in try to convert data relation from Data set tables to xml to make an XmlDataSource supply it to Dynamic Menu Control.
This is the Code behind
DataSet ds = new DataSet();
SqlCommand cmdmenu = new SqlCommand("select CategoryID,CategoryName from Category ", ConManager.Con());
SqlCommand com2 = new SqlCommand("select CategoryIDToSub,subcategoryid ,SubCategoryName from CategorySub", ConManager.Con());
SqlCommand cmd3 = new SqlCommand("select subcategoryid 'SubCategoryID2',Sub2CategoryName from CategorySub2", ConManager.Con());
SqlDataAdapter menadapter = new SqlDataAdapter(cmdmenu.CommandText, ConManager.Con());
SqlDataAdapter menadapter2 = new SqlDataAdapter(com2.CommandText, ConManager.Con());
SqlDataAdapter menadapter3 = new SqlDataAdapter(cmd3.CommandText, ConManager.Con());
menadapter.Fill(ds, "Menu");
menadapter.SelectCommand = com2;
menadapter2.Fill(ds, "SubMenu");
menadapter3.SelectCommand = cmd3;
menadapter3.Fill(ds, "SubSubMenu");
DataColumn colParent =
ds.Tables["Menu"].Columns["CategoryID"];
DataColumn colChild =
ds.Tables["SubMenu"].Columns["CategoryIDToSub"];
DataRelation relation = new DataRelation("relationName",
colParent,
colChild, true);
DataRelation Relation2 = new DataRelation("relationName2",
ds.Tables["SubMenu"].Columns["subcategoryid"],
ds.Tables["SubSubMenu"].Columns["SubCategoryID2"], true);
relation.Nested = true;
Relation2.Nested = true;
ds.Relations.Add(relation);
ds.Relations.Add(Relation2);
XmlDataSource.Data = ds.GetXml();
if (Request.Params["Sel"] != null)
Page.Controls.Add(new System.Web.UI.LiteralControl("You selected " + Request.Params["Sel"]));
and this is the Xslt File Code
and this is the Menu Control and the XmlDataSource Code
and the Xml Output dosn't contain more than one Root , This is the Xml output
Ehab ElfahamPosted May 25, 2011, 5:46 AM
Sam HobbsPosted May 24, 2011, 4:32 PM
Since no one has been able to help yet, I think you need to determine where the error message is coming from. I assume this is an ASP application and I am not experienced with debugging them. Perhaps it will help you to become more familiar with debugging ASP pages. I hope Suthish can help with that but I know there are many useful articles in this web site.
Ehab ElfahamPosted May 24, 2011, 10:22 AM
Sam HobbsPosted May 24, 2011, 1:00 AM
Also, can you tell us what line of code that the exception occurs at?
Ehab ElfahamPosted May 23, 2011, 6:38 PM
Suthish NairPosted May 23, 2011, 1:22 PM
Am not sure...
Can you remove these xml nodes (marked in bold) and try..