Hi there,
I would like to know how to insert a navigateurl in my page.....everything works fine, except I can't seem to insert a navigateurl statement.
I would like to goto a page called *webcategory.aspx?"ATTACH THE ID HERE"* (but first I would like to know how to create a link in the first place.....currently while executing the following code I receive the following error :(
THANKS!
--------------------------
ERROR
Compiler Error Message: CS0117: 'Microsoft.Web.UI.WebControls.TreeNodeCollection' does not contain a definition for 'NavigateUrl'
Source Error:
Line 35: {
Line 36: nodes.Add( Node( dr["webpage_category_name"].ToString(),dr["webpage_category_id"].ToString() ) );
Line 37: nodes.NavigateUrl = dr("webpage_category_name");
Line 38:
Line 39: }
--------------------
<%@ Page Language="C#" debug="true"%>
<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls" %>
<%@ import namespace="System.Data" %>
<%@ import namespace="System.Data.SqlClient" %>
<%@ import namespace="Microsoft.Web.UI.WebControls" %>
<script language="C#" runat="server">
public void Page_Load(Object src,EventArgs e) {
GetCategories("0",TreeCtrl.Nodes);
}
private void GetCategories( string parent, TreeNodeCollection nodes )
{
// add nodes for categories
// Creating the database connection
SqlConnection objConn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_STRING_conn_main"]);
// Creating the stored procedure
SqlCommand webpage_category = new SqlCommand("stpr_webpage_category_view",objConn);
webpage_category.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
da.SelectCommand = webpage_category;
da.Fill( ds, "webpage_category_name" );
DataView dv = ds.Tables[0].DefaultView;
dv.RowFilter="webpage_category_parent_id=" + parent;
foreach( DataRowView dr in dv )
{
nodes.Add( Node( dr["webpage_category_name"].ToString(),dr["webpage_category_id"].ToString() ) );
// THIS IS WHERE I GET THE ERROR!
nodes.NavigateUrl = dr("webpage_category_name");
}
for( int i = 0; i < nodes.Count; i++ )
{
GetCategories( dv[i]["webpage_category_id"].ToString(), nodes[i ].Nodes );
}
}
// create a TreeNode from the specified path, text and type
private TreeNode Node(string text, string id)
{
TreeNode n = new TreeNode();
n.Text = text;
n.ID = id;
return n;
}
</script>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<iewc:treeview id="TreeCtrl" runat="server" DefaultStyle="background:white;color:black;font-family:Verdana;font-size:10pt"
HoverStyle="background:white;color:black;font-size:10pt;border:solid 1px;"
SelectedStyle="background:white;color:red;font-weight:bold"></iewc:treeview>
</body>
</html>