Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Cant access TreeView Node frm Btn Click event after populating frm another click even

Reply
Thread Tools

Cant access TreeView Node frm Btn Click event after populating frm another click even

 
 
chandrajit_in chandrajit_in is offline
Junior Member
Join Date: Jan 2008
Posts: 1
 
      01-03-2008
This is very urgent
I am using Visual Studio 2005, TreeView Control.

In aspx page only TreeView Control is create. Code is given below:
---------------------------------------------------------------------
<asp:TreeView runat="server" ID="tvUser" Visible="true">
</asp:TreeView>

--------------------------------------------------------------------

Above treeview is populated in a button click event. Code is given below:
--------------------------------------------------------------------
private void btnUser_Click(object sender, EventArgs e)
{
lblError.Text = string.Empty;
// Execute Stored Procedure and get Node list as DataTable
DataTable moTable = UserMapping.GetUserMapping(Convert.ToInt32(dropPro cess.SelectedValue),
Convert.ToInt32(dropTeam.SelectedValue),
Convert.ToInt32(dropSkillType.SelectedValue),
Convert.ToInt32(dropSkillLevel.SelectedValue),
Convert.ToInt32(dropQC.SelectedValue));
tvUser.Nodes.Clear();
chlstuser.Items.Clear();
TreeNode mNode = null;
// ADD ROOT NODE
mNode = new TreeNode();
mNode.Value = dropTeam.SelectedValue + "T";
mNode.Text = dropTeam.SelectedItem.Text;
mNode.ToolTip = dropTeam.SelectedItem.Text;
tvUser.Nodes.Add(mNode);
// ADD CHILD NODE AND OTHER NODE
foreach (DataRow moRow in moTable.Rows)
{
mNode = new TreeNode();
mNode.Value = moRow["inID"].ToString();
mNode.Text = moRow["vcText"].ToString();
mNode.ToolTip = moRow["vcText"].ToString();
mNode.Checked = Convert.ToBoolean(moRow["bolChecked"]);

if ((mNode.Checked))
{
ListItem mListItem = new ListItem(moRow["vcText"].ToString(), moRow["inID"].ToString());
chlstuser.Items.Add(mListItem);
}
string mParentKey = moRow["inParentID"].ToString();

if (mParentKey != "")
{
foreach (TreeNode mSearchNode in tvUser.Nodes)
{
if (mSearchNode.Value == mParentKey)
{
mSearchNode.ChildNodes.Add(mNode);
break;
}
else if (mSearchNode.ChildNodes.Count > 0)
{
AddNodeToTree(mSearchNode, mNode, Convert.ToInt32(mParentKey.Trim()));
}

}

}
}
}

public void AddNodeToTree(TreeNode PresentNode, TreeNode NewNode, Int32 ParentID)
{
if (Convert.ToInt32(PresentNode.Value) == ParentID)
{
PresentNode.ChildNodes.Add(NewNode);
}
else
{
if (PresentNode.ChildNodes.Count > 0)
{
foreach (TreeNode cNode in PresentNode.ChildNodes)
{
AddNodeToTree(cNode, NewNode, ParentID);
}
}
else
{
if (Convert.ToInt32(PresentNode.Value) == ParentID)
{
PresentNode.ChildNodes.Add(NewNode);
}
}
}

}

--------------------------------------------------------------------

Nodes are populated properly.
After populating the nodes I am trying to access all those nodes in another Button Click event in the same page.

Relivant code is
tvUser.Nodes

But this time TreeView is not returning any of the node which are populated in previous Button Click Event.

Its showing
tvUser.Nodes.Count = 0
Please let me know, under such a scenario, how shall I get access all those nodes.

Its urgent.... any body please help.
My mail id is
chandrajit.samanta 'at' gmail dot com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl variable $node/text() but $node can non-node-set help! Tjerk Wolterink XML 2 08-24-2006 03:28 AM
How to set the node indent property between the parent node and the leaf node viveknatani@gmail.com ASP .Net 0 02-13-2006 07:11 PM
Adding JavaScript to focus on a section of the page after btn oncl =?Utf-8?B?UEs5?= ASP .Net 4 03-06-2005 07:07 PM
How to drag a sub-node to another node in TreeView? wolf ASP .Net 0 08-18-2004 11:51 PM
frm["custom"] vs frm.getAttribute("custom")? F. Da Costa Javascript 3 01-30-2004 11:54 AM



Advertisments