本文整理汇总了C#中System.Web.SiteMapNodeCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# SiteMapNodeCollection.Add方法的具体用法?C# SiteMapNodeCollection.Add怎么用?C# SiteMapNodeCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.SiteMapNodeCollection
的用法示例。
在下文中一共展示了SiteMapNodeCollection.Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadSiteMapData
// The LoadSiteMapData() method loads site navigation
// data from persistent storage into a DataTable.
DataTable siteMap = LoadSiteMapData();
// Create a SiteMapNodeCollection.
SiteMapNodeCollection nodes = new SiteMapNodeCollection();
// Create a SiteMapNode and add it to the collection.
SiteMapNode tempNode;
DataRow row;
int index = 0;
while (index < siteMap.Rows.Count)
{
row = siteMap.Rows[index];
// Create a node based on the data in the DataRow.
tempNode = new SiteMapNode(SiteMap.Provider,
row["Key"].ToString(),
row["Url"].ToString());
// Add the node to the collection.
nodes.Add(tempNode);
++index;
}
示例2: GetChildNodes
// Implement the GetChildNodes method.
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node)
{
SiteMapNodeCollection children = new SiteMapNodeCollection();
// Iterate through the ArrayList and find all nodes that have the specified node as a parent.
lock (this)
{
for (int i = 0; i < childParentRelationship.Count; i++)
{
string nodeUrl = ((DictionaryEntry)childParentRelationship[i]).Key as string;
SiteMapNode parent = GetNode(childParentRelationship, nodeUrl);
if (parent != null && node.Url == parent.Url)
{
// The SiteMapNode with the Url that corresponds to nodeUrl
// is a child of the specified node. Get the SiteMapNode for
// the nodeUrl.
SiteMapNode child = FindSiteMapNode(nodeUrl);
if (child != null)
{
children.Add(child as SiteMapNode);
}
else
{
throw new Exception("ArrayLists not in sync.");
}
}
}
}
return children;
}
protected override SiteMapNode GetRootNodeCore()
{
return RootNode;
}
// Implement the GetParentNode method.
public override SiteMapNode GetParentNode(SiteMapNode node)
{
// Check the childParentRelationship table and find the parent of the current node.
// If there is no parent, the current node is the RootNode.
SiteMapNode parent = null;
lock (this)
{
// Get the Value of the node in childParentRelationship
parent = GetNode(childParentRelationship, node.Url);
}
return parent;
}