TreeView woes in VS2005

J

Josh

Hi,

I'm trying to use the standard TreeView in VS2005 ( under the navigation
menu ). But I cant get any events to postback and none of the style
settings are being applied. None of the property settings seem to be
working either. The "ShowLines" property ( and others ) is working in the
designer but not when the page renders

I must be missing something simple, but for the life of me, I cant see what
it is.

HELP!
 
M

Mark Rae

I'm trying to use the standard TreeView in VS2005 ( under the navigation
menu ). But I cant get any events to postback and none of the style
settings are being applied. None of the property settings seem to be
working either. The "ShowLines" property ( and others ) is working in the
designer but not when the page renders

I must be missing something simple, but for the life of me, I cant see
what it is.

What you've actually forgotten to do is post your code so that we can help
you...
 
J

Josh

What you've actually forgotten to do is post your code so that we can help

Heres what I'm doing to populatethe node. They all appear. The doPostBack
is running but no server side event fires.

private void loadMenu()

{

//clear up any existing nodes

TreeView1.Nodes.Clear();



// get the data for the nodes

SqlStatement query = new StoredProcedure(@"SelectMenu");

DataTable table = query.ExecuteDataTable();



// process each parent tree node

foreach (DataRow dr in table.Rows)

{

if (dr["biParentSiteMapNodeID"] == DBNull.Value)

{

TreeNode tn = new TreeNode(dr["vcTitle"].ToString(),
dr["biSiteMapNodeId"].ToString());

AddChildMenuNodes(tn,table);

TreeView1.Nodes.Add(tn);

}

}





}



/// <summary>

/// recursive function to populate tree nodes

/// </summary>

/// <param name="tn">parent tree node</param>

/// <param name="dt">complete datatable of all menu nodes</param>

private void AddChildMenuNodes(TreeNode tn, DataTable dt)

{

int parentID = Convert.ToInt32(tn.Value); // parent id for who's
children we are looking



foreach (DataRow dr in dt.Rows)

{

if (dr["biParentSiteMapNodeID"] != DBNull.Value)

{

if (Convert.ToInt32(dr["biParentSiteMapNodeID"]) ==
parentID)

{

TreeNode newTreeNode = new
TreeNode(dr["vcTitle"].ToString(), dr["biSiteMapNodeId"].ToString());

AddChildMenuNodes(newTreeNode, dt);

tn.ChildNodes.Add(newTreeNode);

}

}

}

}
 
J

Josh

Hmm - well, unless I'm missing something, I can't actually see a
server-side event such as SelectedNodeChanged...

Actually theres no code in it to show, because its' not firing!
 
M

Mark Rae

Actually theres no code in it to show, because its' not firing!

Er, well, two possibilities, then...

1) you don't have the property set (correctly) in your webcontrol tag...

2) the event hasn't been wired up...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top