TreeView woes in VS2005

  • Thread starter Thread starter Josh
  • Start date Start date
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!
 
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...
 
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);

}

}

}

}
 
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!
 
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...
 
Back
Top