Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP.NET (Non-Forum Related)
 populating treeview control from db. how about URL
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

blackinwhite
Average Member

Turkey
657 Posts

Posted - 02 December 2006 :  04:16:23  Show Profile
Hi all,

I have this code, populating treeview from DB. It works ok, but I can't control the urls, how can I change the URL property of a node?



Best



private void insertNodes(TreeNode n, int module_id)
{
SqlConnection con=new SqlConnection(@"server=SPARK\ISO;uid=sa;pwd=sa;database=ISODB");
con.Open();
SqlCommand cmd=new SqlCommand( "SELECT * FROM [module] WHERE parent_module=" + module_id,con);
SqlDataReader rdr=cmd.ExecuteReader();
while(rdr.Read())
{
TreeNode t=new TreeNode(rdr["module_name"].ToString(), rdr["module_id"].ToString());

insertNodes(t,Convert.ToInt16(rdr["module_id"].ToString()));
if(n==null)
{
treeView1.Nodes.Add(t);
}
else
n.ChildNodes.Add(t);
}
rdr.Close();
con.Close();
Dispose();
}

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 02 December 2006 :  04:35:19  Show Profile  Visit HuwR's Homepage
after this line
TreeNode t=new TreeNode(rdr["module_name"].ToString(), rdr["module_id"].ToString());

you would set
t.NavigateUrl = whateveryour url is;
Go to Top of Page

blackinwhite
Average Member

Turkey
657 Posts

Posted - 02 December 2006 :  04:52:04  Show Profile
Huwr, you're just saved my 10-hours-time-wasting routine. :)

thanks a lot
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000 Version 3.4.07