.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

The specified node cannot be inserted as the valid child of this node, because the specified node is

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :ASP.Net

I am trying to display a portion of an xml file in a data grid.  I need to transform a number of elements to attribute to display in the grid. If i delete all of the additional elements in the xml file, my code works.  however i need those elements to remain in the XML file. So, here is what i got, maybe someone can help:

Working XML file (not useful):

<?xml version="1.0" encoding="utf-8"?>

Not working xml (need to have it work):

<?xml version="1.0" encoding="utf-8"?>

View Complete Post

More Related Resource Links

Display homepage node along with child nodes


If the first Sitemap node is your homepage/default and all other nodes are supposed to be children / grandchildren of the first sitemap node in a web.sitemap, how do I set up my web.sitemap to enable me to display my cssFriendlyMenu with the homepage node along with the nodes that are 1 level down from it at the same time as in :

Home   Products   Services   About us


...or is it not possible to have the first sitemap node displayed along with the nodes that are 1 level down from it?  Do I need to have a different starting node rather than my homepage node?

Display error if a treeview root node contains a child node

I am having a treeview initially with a root node when form is loaded. I will add child node as some.txt file at the runtime by selecting an option as Addnew from contextmenu which was displayed when the user right clicks on the root node. Now what i need is if the tree has child node appended to the Root and if user tries to create a new node by clicking the option addnew from context menu i would like to display an error as only one child allowed.   Can any one help

delete node based on child value

Trying to delete a node via linq to xml but don't seem to be creating my query just right. My xml looks like this: <Index><Document>    <FriendlyName>test</FriendlyName>    <ID>f1eb6439-56dc-4f8a-a02a-c97706646643</ID>    <Post>True</Post>    <Department>Clearance</Department>    <Category>Information</Category>    <Audience></Audience>    <Link Type="Page" Target=""><![CDATA[]]></Link>    <Keywords></Keywords>  </Document></Index>   I know the ID that i want and is stored in variable myID Now I need to search my xml & find the entry that matches myID Then delete the entire Document element & all child nodes.   Here's what I've been playing with but it's just not quite there. myxmldoc.Elements("Document").Where(s => s.Element("ID").Value == myID).Remove();    Thanks ahead for the help!

Add to xml node as a first child


Hi Folks,

I am new with ASP.NET, trying to build an application with the help of googling, now in XML section when I am updating my XML dynamically, by default the node would be added after the last node, I want to add it as a first child (as first child of <total> so that I can save sorting portion at data grid. Please have a look on the code and suggest me.




protected void BtnSubmit_Click(object sender, EventArgs e)


            string xx="", yy="", zz="",
            datacable = "",
            charger = "",
            issued_by= "";
            LblSummary.Text = "";
            Lblmsg.Text = "";

Displaying + on treeview node even when no child nodes are present


I have a treeview control that is working great, except that I would like the behavior of some nodes to display the + even though no child nodes exist yet. Meaning, I want my treeview control to look like this:

- RootNode
    + Node1
    + Node2
    + Node3

However, Nodes 1, 2, and 3 do not have any child nodes. From what I can see the + or - does not display if there are no child nodes, but I would like to see the + appear even though there are no child nodes. I want to do this because I want to create the child nodes upon expanding the parent node (Node1 for example).

Is this possible?



how to make a TreeNode in treeview as the 1st child node for every or specific Parent Treenode? w




How to  make a treenode  as the 1st child node for every parent node or for some specific parent nodes.

thanks in advance

about error in child node in menu



I created menu control and child nodes in .aspx page.i created childs also. where i created childs it is displayig "expand" instead of child name. the links has not working.but running it will run without error but displaying like the follwing.i didnt do any formatting simply created a menu.

Please help me to solve it.




Skip Navigation Links

Company Details
Process Owner's Details Expand Process Owner's Details

WPF Selected xml node from treeview, I want to populate a datagrid with that node and all child node

I have populated a tree view from a xml.  I know want to take the node and all children that has been selected by double clicking on the tree node and populate a data grid.

only outputs first child node

<?xml version="1.0" encoding="utf-8"?>
     <category id="10" name="Amet"/>
     <category id="20" name="Dolor"/>
     <category id="30" name="conse"/>
     <category id="40" name="Lorem"/>
	<product id="1905" title="KKLorem ipsum dolor sit amet, consectetur a" description="bbloren ipsum dipsum" >
	  <category id="10"/>
	  <category id="20"/>
	  <category id="30"/>
	  <category id="40"/>
	<product id="2100" title="JJLorem ipsum dolor sit amet, consectetur a" description="aaloren ipsum dipsum" >
	  <category id="20"/>


Code used to read the above file


string pathToXml = Server.MapPath("/App_Data/DataFile.xml");
XDocument order = XDocument.Load(pathToXml);

var products = from c in order.Element("catalog").Elements("categories")
 select new {   po = c.Element("category").Attribute("id").Value   };

foreach (var item in products)
  { Response.Write(item.po); }

The above code only outputs the first line

?????????<category id="10"  name="Amet" />

 I thought the

Check child node exists in XML using LINQ

In this article I will show you, how to verify the child elements/nodes are exists in the XML while selecting values from the XML using LINQ.

ImageURL SiteMap Node


Hi Can anyone tell me how i can add the ImageURL from a sitemap into a navigation menu, i had this working with webforms but cannot get it to work with mcv

var sbMenuHelper = new StringBuilder();

sbMenuHelper.Append("<ul class='cssMenu'>");

var topLevelNodes = SiteMap.RootNode.ChildNodes;
foreach (SiteMapNode node in topLevelNodes)
    if (SiteMap.CurrentNode == node)
        sbMenuHelper.AppendFormat("<a href='{0}'>{1}</a>", node.Url, helper.Encode(node.Title));

return sbMenuHelper.ToString();

        description="Contact Us"

Addressing a specific node with CSS Friendly Control Adapters


Hello everybody,

I like the concept of the friendly control adapters, but I'm not sure if I can use them for my purpose.
My whole menu basically consist of one image, which itself contains the images for each menu item (is that understandable?).

Each menu item then displays only a certain part of the image.
I do this by shifting the background-position.

#navigation li#home a{
background-position:0px 0px;

/* Registration */
#navigation li#registration a:link, li#registration a:visited {
background-position:-106px -34px;

#navigation li#registration a:hover, li#registration a:focus {
background-position:-106px 0px;

/* Administration */
#navigation li#administration a:link, li#administration a:visited{
background-position:-212px -34px;

#navigation li#administration a:hover, li#administration a:focus{
background-position:-212px 0px;


I would like to do the same now with CSS Friendly, but I don't see how I can address each individual menu item node.
In static HTML I can give each link an ID (i.e. #administration), but I don't see how to do this with the asp:Menu control and CSS Friendly.

Can someone help me?

Thanks a lot,

(Imperfect) Solution to TreeView Postback / Client-Side Node Selection Issue


I've seen this question posted on all corners of the web... "How do I disable "AutoPostBack" on the ASP.NET 2.0 TreeView control?!"  Unfortunately, most of the answers either don't work, miss the point (don't work right), or boil down to "You can't do it."  I happen to know that this behavior worked perfectly in the IEWebControls TreeView that Microsoft released as an add-on prior to ASP.NET 2.0, however.  So I set out to find a solution for the ASP.NET 2.0 TreeView issue.

In a nutshell, the behavior that I and others are looking for is to have a TreeView rendered in a page that allows the user to expand, contract, and select nodes within the TreeView without causing a PostBack to the server.  This implies two things: (1) the most recently-selected node should be recorded as the currently-selected node [i.e., at PostBack time, the most-recently selected node is actually represented as the SelectedNode]; and (2) the selected node should exhibit the SelectedNodeStyle as specified in the TreeView declaration.

It appears that the TreeView engineers saw only two possible outcomes from selecting a leaf node in a tree: (1) immediately posting back to the server, or (2) immediately navigating to another web page.  They apparently did not consider option (3) just allowing selection in-place on the client, while waiting for a click on so

Node probability distibution - values don't sum to 1?

Hi, I am using sequence clustering algorithm and I have checked Node probability distribution (state transition) for one of the cluster. Probability values don't sum to 1. Why? I think they should. Do I miss something?

LinQ to check if xml node exists in the XML??

Using LinQ or any C# syntax, I just want to know whether "Item" Child exists or not if the parent Node (ChildMenuSelected>>MenuSelected) are true from the below xml format.Xml Format:<MenuDataResult> <Items> <Item> <ItemType>Submenu</ItemType> <ItemTitle>Level22</ItemTitle> <Menu> <MenuSelected>false</MenuSelected> <ChildMenuSelected>false</ChildMenuSelected> </Menu> </Item> <Item> <ItemType>Submenu</ItemType> <ItemTitle>Level21</ItemTitle> <Menu> <MenuSelected>false</MenuSelected> <!--if ChildMenuSelected = true --> <ChildMenuSelected>true</ChildMenuSelected> <Item> <ItemType>Submenu</ItemType> <ItemSubType>0</ItemSubType> <Menu> <!--if MenuSelected = true --> <MenuSelected>true</MenuSelected> <ChildMenuSelected>false</ChildMenuSelected> <!-- whether this below item exists or not --> <Item> <ItemType>Submenu</ItemType> <Menu> <MenuSelected>false</MenuSelected> <ChildMenuSelected

MOSS Site with Basic Authentication and variations does not work on one node

Hi, We have one MOSS Farm with two nodes, on this we have several sites. For one specific site we have Basic Authentication and variations enabled in it, on one node site works fine. When we browse it pops-up for credentials and once credentials are provided it works fine and properly redirect to source variation home page. But on the other node when we browse the site it pops-up asking for credentials then after providing correct credentials it again asks for credentials twice and then it throws the following error : Access denied.   You do not have permission to perform this action or access this resource. And if we directly put the source site homepage url it throws following error: 401 UNAUTHORIZED We have checked the Alternate Access Mappings for the site and it is perfectly fine, if i enable windows authentication on the defected node the site works fine. This issue is just like pain in the neck still no resolution, please help us to resolve this issue. Regards, Jasjeet Singh
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend