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

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

Multiple Child Nodes with For XML Path

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :Sql Server
I am trying to generate this format of xml and having difficulties because of the properties section. I can have unlimited number of properties and "For XML" tells me it can't generate the same node "Properties/@Name". I have tried several methods online, but can't seem to get it to work. OptionLists> <OptionList Name="Functions"> <Option Value="L9496"> <Properties Name="Description" Value="L9496 - Privacy Lock With Indicator" /> <Properties Name="Locked" Value="False" /> </Option> <Option Value="LV9040" /> <Option Value="L9485" /> </OptionList> </OptionLists>   My SQL currently looks like this: SELECT 'Functions' as '@Name', ( Select coalesce(nullif(No_,'),'NONE') "Option/@Value", Case NO_ when isNull(nullif(NO_,'),null) Then 1 Else 99 END "Option/@Order", 'TRUE' "Option/@Visible", 'FALSE' "Option/@Locked", ' "Option/@ToolTip", ' "Option/@ImageLink", ' "Option/@InfoMessage", 'QtySensitive' "Option/Properties/@Name", Case [Quantity Sensitive] When 0 Then 'False' When 1 Then 'True' End "Option/Propert

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?

Child nodes not allowed.


Hi everyone.

I'm positive that, by now, a lot of people have run into this problem but even with all the forum posts with great answers, I still can't seem to get to the bottom of it. Here are some specs:

  • Windows Server 2008
  • Visual Studio 2008 x86

So here's the issue:

I have VS2008 installed on the server listed above. This is our development server and everything is created and tested here. I have created an asp.net application, tested it on the dev. environment and everything works great. When I try to migrate this application up to our Quality Assurance environment (which is Windows Server 2003), I get the error in the subject title.

I've read many things that can be the cause of this and I'm positive that I know 2 ways of fixing it. One is from this post: Simple web site problem on Vista, related to <providerOption>, and the other is making sure 3.5 framework is at least installed on the server in question. There are 2 reasons why I'm unable to use these 2 methods:

  • The patches from DVD that I'm supposed to install won't let me install them. Upon double clicking I recieve a message saying the "Update is not applicable to your computer"
  • I don't have permission to install 3.5 frame

WPF- Treeview--How to add child nodes-- a Bizzare problem-- plz help

so here it is.... in WPF ... Treeview control -- i can add nodes under root node, using XAML code  which is static i hav to add the nodes, using C# code which is dynamic. For Example: Menu Table MenuId       Name       ParentId     1           Country         0     2           India             1     3           USA              1     4           AP                2     5           UP                2     6           California      3     7           Newyork       3 In my C# Code i took a class file in that, i declared the menu() method of type DataTable. Method menu() :- I created a temptable (using DATATABLE CLASS) with same fields(using CLONE()) and filled it with MENU table data and returned that temptable. So now i have data with me. Based on ParentID i can retrieve the child values. but how to add those values to TREEVIEW as its ITEMS There is no---> " treeview1.Items[0].Items.Add() " thing in WPF--- n its creating problem to me. Hw can i do dat...? i dnt knw which Methods , Properties , Classes  to Use. Ex:       + COUNTRY             + INDIA                    AP                    UP              +USA                    Lusiana                    Nwyrk Please help. Thank you. Beginner in WPF..... VENU.Beginner in WPF.......VENU

Method/Way to know whether a input path of FilesSystem contains any Child file/folder or not

Hi,I am looking for a Method/Way to know whether a input path of FilesSystem contains any Child file/folder or not. To know it currently I am using "Directory.GetFileSystemEntries(Path).Count" and checking if count > 0 then returning True else False. For this first method calculates all the files and folder and then return status to me but I want to exit out as soon as my method gets first element(file/folder) in specified path. Because above method is timing out when my input path contains more than 1 million files. I just need to check whether input folder path contains any child file/folder or not. I have tried to use Win32 API also but on ther server it is crashing so I donot want to use that solution. In .NET any method or way is present to know it. Please suggest me.

WPF TreeView child nodes - collection is not a member of the first level nodes object



I was wondering if i could use a TreeView to display data from 2 separate collections where both collections are members of the same object. For example i have a view model that has 2 observable collections:



Each model has a property Brand which specifies the brand for each model. What i want to do is bind the first level to the Brands collection and the second level to the Models collection and specify a filter.

Thanks in advance.

add child nodes to treeview control

 private void updateTreeView(IMongoCollection one)
      ICursor coll= one.FindAll();
      int count=0;
      foreach (Document document in coll.Documents)
       TreeNode mynode= treeView1.Nodes.Add(count.ToString());
       enumerateValues(document.GetEnumerator(), mynode);



    private void enumerateValues(IEnumerator<KeyValuePair<string, object>> iEnumerator, TreeNode parentnode)
      //TreeNode childnode = parentnode.Add(iEnumerator.Current.Key.ToString());
       if(iEnumerator is IEnumerable)
         // ADD THE KEY
         TreeNode childNode = parentnode.Nodes.Add(iEnumerator.Current.Key);

         enumerateValues(iEnumerator.Current.Value, childNode);
         /// add the value

Multiple nodes with the same URL


I'm trying to build a sqlsitemapprovider. I gets the error "Multiple nodes with the same URL" I can't figure out what I'm doing wrong, I hoipe anyone can help me. There is no duplicate url in the db.

public override SiteMapNode BuildSiteMap()
        lock (this)
            // Don't rebuild the map unless needed.
            // If your site map changes often, consider using caching.
            if (rootNode == null)
                // Start with a clean slate.
            // Get all the data (using provider-agnostic code).
            DbProviderFactory provider = DbProviderFactories.GetFactory(providerName);
            // Use this factory to create a connection.
            DbConnection con = provider.CreateConnection();
            con.ConnectionString = connectionString;
            // Create the command.
            DbCommand cmd = provider.CreateCommand();
            cmd.CommandText = storedProcedure;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = con;
            // Create the DataAdapter.
            DbDataAdapter adapter = provider.CreateDataAdapter();
            adapter.SelectCommand = cmd;
            // Get the results in a DataS

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?



Google base: Non-child nodes with the same name


Not and xml expert, so please be kind to me.  I'm trying to consume a google base fomatted feed (for these purposes just bulding a long string).  I'm having a problem with stuff on my main/first node level with the same name e.g. "g:feature".  Any xml I've dealt with before would have these as child nodes to, say, "g:features" and I would just loop through them as such.  Can anyone help?

Dim doc As New XmlDocument()

        ' Load data  

        ' Get nodes with XPath  
        nodeList = doc.SelectNodes("/rss/channel/item")

            'loop through XML nodes and display them
            For Each node As XmlNode In nodeList

                texter += node.Item("title").InnerXml.ToString
                texter += "<br />"
                texter += node.Item("g:feature").InnerXml.ToString
                texter += "<br />"

How to create a View to return all multiple child fields in one record?


I have an application where the users can define up to 5 extra fields for a particular table (e.g. tblMaster). The custom data is all held in one table (e.g. tblCustom) so there could be up to 5 records in tblCustom for each tblMaster record. In my application I build a select statement based on the number of custom fields so that I can get a single row of data for each tblMaster record (sample below). I am now adding new features to the application and I want to expose an SQL View to the users for a report writer that will achieve the same result but still cater for the variable number of custom fields. I realise this needs to use probably a RIGHT OUTER JOIN so that NULL is returned if there is no matching field but I can't work it out. If I had five separate files it would be easy as each one would be a RIGHT OUTER JOIN for each. I could build 6 views (e.g. with no custom fields, with one custom field, with two custom fields etc) but that is not very efficient. I don't particulaly want to restructure the database as there would be a lot of work and retesting.
Any help would be very welcome!

SELECT tblProcess.ProcessNumber, tblProcess.Process, tblProcess.Risk, tblProcess.MRR, tblProcess.Version, tblProcess.LastChange, tblProcess.SecurityLevel, 

Best design option for multiple parent / multiple child list?


I made 2 lists.  "User Groups" and "Resource Groups".  In User Groups, I setup a column to do a multi-select lookup to the Resource Groups lists title column.  Obviously as this gets built, groupings will form in the other direction as well... Is there a way to programatically do that, so I don't have to complete a multi-select colum in the Resource Groups list that does a lookup to the User Groups list to get info I logically already have.

I tried to do it with a workflow, but was only able to update 1 item so the multi-select concept was pointless. 

I want to have the multi-select information displayed regardless of which list your looking in.  If you look in a User Groups list item, you can see all the resources the users have access to... if you look at a Resource Group list item, you can see what User Groups have access to it (linked by multi-select lookup), and i'd like to only have to populate the lookup in 1 direction and build the reverse relationships on automatically.

Hope that makes sense.  You'd think you could auto import this info but I can't get Domain Local groups to show up, seems to be a limitation of the WSDL for connecting to AD (forget the correct term for that piece), so I'll add them manually..



Multiple Parent Child Hierarchies in SSAS 2008 R2


I'm trying to create a dimension containing financial accounts in SSAS 2008 R2 where individual accounts can belong to one or more hierarchies.  I also need to be able to specify a unary operator since a leaf level account may be subtracted from one parent but additive to another parent.  For example revenues and expenses may be grouped one way for statutory reporting and a completly different way for management reporting and further belong to some arbitraty groupings that users find necessary.

I can't seem to find a way to have a leaf level member in a dimension more than one time in a Parent child hierarchy, and I can't seem to find any way to include the unary operator in a hierarchy where I use attributes to define the hierarchy.

Are there any work arounds that anyone knows about?  What I found from the help file was that multiple parent child hierarchies which supported in SSAS 2000 are not supported in 2008.  However there is no suggestion for what to do.

Any insight would be greatly appreciated.


Bill Webster

TreeView with parent to single child relation from multiple children c#



how to populate treeview  with a child node and with all its parent nodes





       -----a11 // if selected i want to draw treeview with its all parents






Custom Control: Multiple children, "{0} can accept only one child."


Long story short - I'm trying to build a custom accordion control that in essence is a Scroll Viewer wrapped around a Stack Panel.  Once I get past the hump I'm at now which is getting the custom control to accept multiple children I should have no further issues.  


Below is my style for the control:


  <Style TargetType="{x:Type local:ScrollableAccordion}">
    <Setter Property="Template">
        <ControlTemplate TargetType="{x:Type local:ScrollableAccordion}">
          <Border Background="{TemplateBinding Background}"
              BorderBrush="{TemplateBinding BorderBrush}"
              BorderThickness="{TemplateBinding BorderThickness}">
          <ScrollViewer Height="{TemplateBinding Height}"
                 Width="{TemplateBinding Width}"

Adding child nodes to its parent



I would like to add child nodes to its parents using pattern visitor to build tree .

 public interface IVisitor
        void Visit(File file);
        void Visit(Level_1 level);
        void Visit(Level_2 level);
        void Visit(Level_3 level);
        void Visit(Level_4 level);
        void Visit(Level_2 level);
        void Visit(Root root);

 public class TreeViewBuilderVisitor : IVisitor
        private TreeNode _treeNode;

        public TreeNode TreeNode
            get { return _treeNode; }
            set { _treeNode = value; }
        private TreeView _treeview;

        public TreeViewBuilderVisitor(TreeView treeview)
            _treeview = treeview;

        public void Visit(File file)
             TreeNode faTreeNode = new TreeNode(file.Name);

        /// <summary>
        /// </summary>

Problem to delete treeNode along with child nodes.



i have a treeView which display organization chart as hierarchical view. i want when end-user remove a treeNode, all childs of the selected node also being removed and then update database. to do this, i've used this code :

private void btnDeleteReceiver_Click(object sender, EventArgs e)

private void DeleteNode(TreeNode node)
      foreach (TreeNode childNode in node.Nodes)
      TestDataSet.ReceiversRow receiver = node.Tag as TestDataSet.ReceiversRow;

as u see in above code, i have a recursive method which delete all child nodes of the parentNode. but i'm facing a problem to delete all childs of the node. this loop could not iterate all childs node correctly. i don't know

Cloud Computing: Synchronizing Multiple Nodes in Windows Azure


Learn how to utilize elasticity-the ability to provision resources and remove them on the fly-to take full advantage of cloud computing.

Josh Twist

MSDN Magazine November 2010

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