![]() |
IOBit Software
|
|
|
||||||
| Programming Place to discuss programming including HTML, Java, C++, MySQL and others. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Sponsored links |
|
|
|
#2
|
|||
|
|||
|
I already found the answer. We can mark this as Resolved.
Thanks |
![]() |
| Tags |
| .net, csharp, tree |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Slave Lake Fires | sibeer | Lounge | 4 | 05-17-11 14:40 |
| Fires, not floods, in the west. | Gregoryno6 | Lounge | 6 | 02-07-11 20:59 |
| Folders (TreeView) & New Explorer Windows | chocobo | Software | 1 | 02-23-09 05:16 |
| Californian Fires | Grumbles | Interesting Website Links | 41 | 11-07-07 01:00 |
| Fires in CA | Lev | Lounge | 4 | 09-30-05 18:20 |