MajorGeeks Support Forums

Go Back   MajorGeeks Support Forums > ----------= PC, Desktop and Laptop Support =---------- > Software
Register FAQ Members List Calendar Casino Mark Forums Read

Software Software such as operating systems like Windows XP, Windows Vista, Windows 7 etc., or specific programs.


Reply
 
Thread Tools Display Modes
  #1  
Old 06-20-12, 09:51
jcast jcast is offline
Private E-2
 
Join Date: Apr 2012
Posts: 17
Thanks: 2
Thanked 0 Times in 0 Posts
Default Treeview onselectednodechanged doesnt fires up

Hi;

I have a treeview comming from database, now I need to click on each category to see the contents (I am doing a FAQ page); well when I add onselectednodechanged property to the treeview I get a compilation error. looks like it does not want to fire up; here is the code:

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:UpdatePanel runat="server" ID="upFAQ" UpdateMode="Conditional">
<ContentTemplate>
<div>
<table class="formTbl width100">
<tr>
<th class="formHeader" colspan="2">Frequently Asked Questions</th>
</tr>
<tr>
<td>
<asp:TreeView ID="treeViewCategories" SelectedNodeStyle-ForeColor="Green"
SelectedNodeStyle-VerticalPadding="0" runat="server"
onselectednodechanged="Select_Change">
</asp:TreeView>
</td>
<td><asp:Label runat="server" ID="Message1"></asp:Label></td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>

=========== Code Behind ========

public partial class FAQ : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
PopulateTreeView(0, null);
}
}

private void PopulateTreeView(int categoryParentId, TreeNode parentNode)
{
var categorySvc = new Shared.Core.CategorySvc();
List<CategoryInfo> allCategories = categorySvc.GetAllCategories();

var filteredItems = allCategories.Where(x => x.CategoryParentId == categoryParentId);

foreach (var cat in filteredItems)
{
TreeNode childNode = new TreeNode();
childNode = new TreeNode(cat.CategoryName);

if (parentNode == null)
{
treeViewCategories.Nodes.Add(childNode);
}
else
{
parentNode.ChildNodes.Add(childNode);
}
PopulateTreeView(cat.CategoryId, childNode);
}
}

private void Select_Change(Object sender, EventArgs e)
{
Message1.Text = "You selected: " + treeViewCategories.SelectedNode.Text;
}
}

if I delete the onselectednodechanged="Select_Change" from the tree view I get my tree fine; but if I add the property back onselectednodechanged="Select_Change" then I got an error:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1061: 'ASP.support_faq_aspx' does not contain a definition for 'Select_Change' and no extension method 'Select_Change' accepting a first argument of type 'ASP.support_faq_aspx' could be found (are you missing a using directive or an assembly reference?)

Source Error:


Line 23: <tr>
Line 24: <td>
Line 25: <asp:TreeView ID="treeViewCategories" SelectedNodeStyle-ForeColor="Green"
Line 26: SelectedNodeStyle-VerticalPadding="0" runat="server"
Line 27: onselectednodechanged="Select_Change">

I need to be able to click on each node and bring the information from the database but I dont know why the onselectnodechanged doesnt work. Can anyone help me please??

Thanks

Alexandra
Reply With Quote
Sponsored links
  #2  
Old 06-20-12, 14:54
jcast jcast is offline
Private E-2
 
Join Date: Apr 2012
Posts: 17
Thanks: 2
Thanked 0 Times in 0 Posts
Default Re: Treeview onselectednodechanged doesnt fires up

I already found the answer. We can mark this as Resolved.

Thanks
Reply With Quote
Reply

Tags
.net, csharp, tree

Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Slave Lake Fires sibeer The Lounge 4 05-17-11 15:40
Fires, not floods, in the west. Gregoryno6 The Lounge 6 02-07-11 21:59
Folders (TreeView) & New Explorer Windows chocobo Software 1 02-23-09 06:16
Californian Fires Grumbles The Lounge 41 11-07-07 02:00
Fires in CA Lev The Lounge 4 09-30-05 19:20


All times are GMT -5. The time now is 12:11.

MajorGeeks.Com Menu

MajorGeeks.Com \ All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ NEW! PC Games \ System Tools \ Macintosh \ Demonews.Com \ Top Downloads

MajorGeeks.Com \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds


All content Copyright MajorGeeks.com source code Powered by vBulletin® Version 3.8.4
Copyright © 2009 vBulletin Solutions, Inc. All rights reserved.
Ad Management by RedTyger