Hello, Ive created a portal that uses a master page in which a TreeView control loads the content for a sitemap after querying a DB (in this case a MySQL db). Ive read this thread (http://forums.asp.net/p/982950/1531734.aspx) and modified David Sussman's code appropriately (the db connection section), and I cant seem to get the treeview control to display anything but the nodes under the root. The nodes that contain children and that are not directly under the root are not displaying (the children nodes do seem to be picked up though via the GetChildNodes fct). I am not sure what the problem is exactly, but when stepping through code, the problem seems to be in here, in the FindSitemapNode function
foreach (KeyValuePair<int, UserDbSiteMapNode> node in _userDbSiteMapNodes[HttpContext.Current.User.Identity.Name])
{
HttpContext.Current.Trace.Write("FSMN", "testing " + node.Value.Node.Url);
if (node.Value.Node.Url == rawUrl)
{
HttpContext.Current.Trace.Write("found");
return ReturnNodeIfAccessible(node.Value.Node);
}
}
When the code hits the children nodes, the RawURL value (passed in as the function parameter) is numerical and therefore the condition is not met and I think this is what causes the children to never show up.
Ive disabled security trimming, Ive added "*" to the Roles, ive copied the data from the SQL table that came with the example... What am I missing? This is the only portion of code that changed, the rest is identical:
// create database provider factory
//DbProviderFactory factory = DbProviderFactories.GetFactory(this._dbProviderName);
//DbConnection conn = factory.CreateConnection();
//DbCommand cmd = factory.CreateCommand();
//DbDataReader rdr;
// set connection and command details
MySqlConnection mscConnection = new MySqlConnection(ConfigurationManager.ConnectionStrings["MySqlLocalSqlServer"].ConnectionString);
MySqlCommand mscmdCmd;
MySqlDataReader rdr;
//mscConnection.ConnectionString = ConfigurationManager.ConnectionStrings[this._connectionStringName].ConnectionString;
//cmd.Connection = mscConnection;
string strQuery = "SELECT * FROM UserMenu WHERE UserName ='" + userName + "'";
//cmd.CommandType = CommandType.Text;
//DbParameter param = cmd.CreateParameter();
//param.DbType = DbType.String;
//param.ParameterName = "@UserName";
//param.Value = HttpContext.Current.User.Identity.Name.ToLower();
//cmd.Parameters.Add(param);
mscConnection.Open();
mscmdCmd = new MySqlCommand(strQuery, mscConnection);
rdr = mscmdCmd.ExecuteReader();