How to specify TreeNodes ordering? Error using WebControls.TreeNodeCollection.AddAt()
<p>I'm trying to add nodes to a TreeView object and I've got the following code that's reading the data from a MySqlDataReader object:</p>

<pre><code>while (no_child_rdr.Read())
{
     TreeNode parentNode;
     int position = no_child_rdr.GetInt16("position");

     // See if the node for this category already exists
     try
     {           
         parentNode = DocumentsTree.Nodes[position];
     }

     catch (Exception ex)
     {
          string category = no_child_rdr.GetString("cat_name");
          parentNode = new TreeNode(category, category);
          DocumentsTree.Nodes.AddAt(position, parentNode); &gt;&gt; This is where my error occurs 
     }

  }
  no_child_rdr.Close();
</code></pre>

<p>The error I end up with is:</p>

<pre><code>Index must be within the bounds of the List.
Parameter name: index
</code></pre>

<p>I'm obviously laboring under the false assumption that I can stick a new <code>TreeNode</code> at any arbitrary place in the <code>TreeNodeCollection</code> using <code>Nodes.AddAt()</code>. Seeing as these objects have a position defined in the database, how should I go about building the <code>TreeNodeCollection</code> such that my nodes are properly ordered?</p>
