C# - How To Implement A Category Hierarchy Using Collections
Apr 14, 2010
I have about 200 categories that are nested. I am currently reading the documention on the C5 generics library. I am not sure if the C5 library is overkill or not. I am looking at converting all my custom algorithms to the C5 implemention.
This is what I need. If a certain category is chosen i need to find its parents, siblings, direct children, and all children.
This is the way I have it set up. To find the:
Parents: I start from the current location then loop through the list and find the current parent. When I find the parent I loop through the whole list again to find the next parent and so on.
Siblings: I loop through the whole list and find all the nodes that have the same parent as the choosen node.
direct children: I loop through the whole list and find all nodes that is a parent of the choosen node.
All Children: This one took me a while to figure out. But I used recursion to find all children of the choosen node.
View 1 Replies
Similar Messages:
Oct 21, 2010
I am having a lot of the same issue as this poster did with errors on initializing type.
I am trying to learn linq and am about ready to give up - don't get how this is easier...
I'm trying to do a simple update to product names in the product table based on the manufacturer ID
In order to do this I am looping through each record. I was initally successful with changing all names in the column but when I try to query the data, I continually run into multiple problems.
The following poster has had the same issue I have but his solution isn't working for me.
[URL]
I keep getting the same error on the opening bracket on the select statement in the SelectByManufacturerID function...
Error 1 Cannot initialize type 'DataBaseDataManagement.ProductName' with a collection initializer because it does not implement 'System.Collections.IEnumerable'
Button that does the actual updating...
[Code]....
The function that the button calls to get the query... ERROR
[Code]....
The class located in Query.cs...
[Code]....
View 3 Replies
Nov 5, 2010
i create example using Northwind database so i create a new website and add new ADO.Net Entity Data Model (.edmx) called Northwind.edmx and i add Categories and Products table inside this (.edmx) file
and add new ADO.Net Data Servuce called "ADODataService" and add it as WebReferences called NorthwindService
so i add new web page and drag DropdownList and Gridview as i want to bind Dropdownlist to all categories and when i select category from Dropdownlist bind Gridview to all Products related to this category
so my code
[Code]....
and my code
[Code]....
so when i select category from Dropdownlist nothing happen :(
also you will find commented code in method BindCategory whuch is not work also.
View 1 Replies
Feb 7, 2010
I'll try to explain as simple as I can in text what my problem is. I don't see any other way to make my issue clear.
I have a GridView that uses an ObjectDataSource.
The ObjectDataSource has an DataObjectTypeName defined, so I pass/get complete objects or list of objects to/from the data access methods.
The objects I'm working with, let's say we work with Book objects, contain a Title and a Category, BUT the Category is an object itself. When the Select method is called, we get a List of Book objects, which is perfectly displayed, overridden ToString method in the Category objects within the Book objects.
The problem I face is that I can't find a way to update the category in my GridView. What I did already accomplish is:I used a template field in the GridView for the Category so I could use a DropDownList for that field in Edit mode.
I bound the DropDownList to another ObjectDataSource that gives me a list of CategoryObjects.
So when I enter Edit mode... the row shows a nice ddl with the available categories. It even selects the right original category.
So far so good... but when I want to save my new selection, I get an error that a string (the selected category in the ddl) cannot be converted to a Category object (that's what the Book object, that is going to be used for the update, expects).
View 5 Replies
Mar 30, 2011
I am working in a project that is a musical website. I want to display the web page with all categories I have. In my database , named Category_Master, I have two fields like Category_Id (which is a primary key ) and Category_Name. I have generated category_Id with NEWID() function. The category_Id is not supposed to display on the web page. But, i have to select Category_Name and according to that , I have to get the category_Id. If I am using Static connection with SqlDataSource, i am able to make visible=false property so that the category_id won't be visible. But , at that time, I can't write code to Select the category_id of the selected index.
If i am using disconnected approach, I filled the dataset with the Category_Master, and binded it to GridView. But, at that time, I can't hide the category_id from the user. I want to select category_id by clicking on the category_name with out displaying category_id ..?
View 4 Replies
Feb 8, 2010
Say I'm currently in the code-behind of a root master page of the web site, and I need to know all the different master pages the page is going through to get to me. How do I do that?
this.Page does in fact give me a reference to the page. But when I get this.Page.Master, it seems to give me a reference to back to me even though I know other master pages are in between.
View 2 Replies
Oct 22, 2010
How can I maintain a 3 level heirarchy by using a gridview?
View 1 Replies
Jan 19, 2010
write a Subroutine that takes a parameter value of a Folder name on the server, then looks for all subdirectories beneath it and puts this hierarchy into a DropDownList?
So far I can't get the sub to work as it stuggles with the path structure and the obvious requirement to call itself.
View 3 Replies
May 10, 2010
tell me the class hierarchy of System.IO namespace?It's not clear in MSDN library.
View 5 Replies
Jun 15, 2010
I'm currently working on a project where I need to segregate some of the views within a controller I have a little better.I want to do something like:
{controller}/{action1}/{action2}/{id}
So let's just say
/Clients/Jobs/Edit/e124929
So I guess I'm looking to have "sub-actions" of my actions?It's achievable with via routing. How should I set the route up for this, and how should I create the routine in my controller to handle the "sub-actions"?
View 10 Replies
Jan 25, 2011
[Code]....
and
[Code]....
Filter for the child controller executes earlier than for the base class... How can i revert that behavior ? Order prop doesn't help...
View 9 Replies
Oct 24, 2010
I have a table in my database which keeps track of a 3 level hierarchy. What is the best way to display and change/modify this hierarchy? Which asp.net control to use and how?
View 1 Replies
Sep 5, 2010
So I'm coding up a simple blogging/content application in MVC2. In my EF domain model I have an abstract entity named "Resource" which serves as a base class for any content that can be published. I have entities named "Picture", "BlogEntry" and "Event" which all inherit from "Resource".
My problem is, it seems it doesn't make collections for Pictures, BlogEntries and Events. I only have a collection of Resources. How can I get collections of the inherited classes? Is it something I'll have to create myself? If so, how?
View 1 Replies
Mar 8, 2010
Trying to figure out how to programmatically access the web pages in the application. Just something simple like a list of them would be awesome. I know I can create a list but I was wondering if there was something that could 'look' at the pages and add a new one to the list if you make a new page for the application.
Example with 7 pages:
Error
Default
Login
Content
Users
ContactUs
Admin
I am half awake so I may be a little unclear. Maybe puting it all in a single question will be easier.
How do you autogenerate a list of all webpages in your current application?
View 1 Replies
Jul 1, 2010
how to create Hierarchy Drop Downlist
View 8 Replies
Sep 13, 2010
I am working on an ASP.net Forms Application that keeps track of information about different offices in an organization. The offices are organized into a hierarchy.
Some users of the program will have access to certain information about all offices in the hierarchy. Some users of the program will have access to only a small part of the hierarchy.
When a user browses for information they are authorized to see, I would like to present the user with a prompt to choose which office in the hierarchy they wish to see information from.
I want to accomplish the following:
A) I want the user to be able to easily navigate the hierarchy of the organization to locate a specific office.
B) I want the user to be able to navigate the hierarchy without refreshing the page.
C) I want my interface to be able to handle a hierarchy at least four layers deep with less than 100 nodes.
I see that Microsoft includes a TreeView control in the standard collection of ASP web controls.
View 3 Replies
Apr 27, 2010
I have the following sql table which contains menu (website menu) data.
Table Name: MenuItems Columns: Id, MenuId, ParentMenuItemId, Text.
My goal is to bind a DDL according to the following hierarchy (example):
Id: 1, MenuId: 1, ParentMenuItemId: -1, Text: 'One'
Id: 2, MenuId: 1, ParentMenuItemId: 1, Text: 'Two'
Id: 3, MenuId: 1, ParentMenuItemId: 1, Text: 'Three'
Id: 4, MenuId: 1, ParentMenuItemId: 2, Text: 'Four'
Id: 5, MenuId: 1, ParentMenuItemId: 4, Text: 'Five'
Requested result in DDL:
One
-- Two
---- Four
------ Five
-- Three
I think it should contain 'WITH' SQL command.
Note: I'm using C#.
View 1 Replies
Jan 13, 2011
I am using VS 2010 for developing asp.net application. we have a requirment to display 3 level hierarchy data into the server controls, how can I do this implementation. My data look like.
Reporting Divisions (1st Level)
Reporting Groups (2nd Level)
Reporting Units. (3rd Level)
Ex:
Division1 Description (1st Level)
Group1 N/A (2nd Level)
Unit1 Unit1 Description (3rd Level)
Unit2 Unit2 Description (3rd Level)
Unit3 Unit3 Description (3rd Level)
Group2 Description (2nd Level)
Division2 (1nd Level)
Group1 Description (2nd Level)
DivisionN Description
how to implement this? And user need to edit the "description" data from the controls also.
View 2 Replies
Sep 28, 2010
I am looking to create an employee hierarchy in a trace tree and have 2 specific fields in my table ( employee , reports to )
Now a sample data looks like follows
Employee Reports to
User A Manager A
Manager A Senior manager A
User B Senior Manager A
User C Manager A
so on and so forth
Now how do I get a trace tree so that when i click on Senior manager A I get Manager A and User B , and then expand manager A to get user A and User C.
View 4 Replies
Aug 19, 2010
I,m having some issues with 3 user controls.heres the scenario.i have 3 UserControls: ctrA and ctrB and ctrC.the idea is: ctrC is collections of ctrB plus some minor info and ctrB is a collection of ctrA plus soe other minor info.ctrA is a simple control with 2 textbox and a label.u enter values on the textbox and the label shows the values multiplied by each other.ctrA is totally inside a updatePanel and when i drag-and-drop it on a custom-page or to ctrC it works just fine (notice that im breaking the disired hierarchy).but when i add it dinamically to ctrB (the correct hierarchy) its not working.the page is being posted back synchronously and worst,the controls desapear.like if they were never there.
View 3 Replies
Sep 28, 2011
I got a IList<Category> where a Category have an id, name and parentid. Right now I loop over all categories where the parent id is 0 (so they are root) and for each of those child categories I call a recursive function that add the child categories to the child nodes. Works fine. However, I (think) I'm going to do away with the asp:treeview since now, next to each Category I want an Edit and Delete Link.
View 3 Replies
Feb 19, 2010
Here I store the hierarchy data for the Organosation. Under_Level_ID denotes under which Level_ID the current Level is lying. e.g. for Branch the hierarchy in above table will be likeHO-->REGION-->Branch & for ZONE the hierarchy will be same as branch. Now my problem is I need all the hierarchy below a given Level. i.e. if am passing 132 as level then the SP should return me all the hierarchy elements lik Zone, Branch, fgfgfhf, Cluster,
CREATE TABLE [dbo].[T_LEVEL_MASTER](
[Level_Id] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
[Org_Id] [numeric](18, 0) NOT NULL,
[Level_Desc] [varchar](100) NULL,
[RM_SB] [varchar](50) NULL,
[Under_Level_Id] [numeric](18, 0) NULL,
CONSTRAINT [PK_T_LEVEL_MASTER] PRIMARY KEY CLUSTERED
(
[Level_Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
View 3 Replies
Feb 20, 2010
For some reason I have a solution with a single project and the solution files are in the same directory as the project is. I consider this ugly and want to change it by moving the solution files in a superordinate directory.
For now I have edited a single line in the .sln file:
Project("{FAE04EC0-AAAA-AAAA-AAAA-00C04F79EFBC}") = "projectname", "projectname.csproj", "{5D5A753D-AAAA-AAAA-AAAA-C535851E8DC8}"
changed to
Project("{FAE04EC0-AAAA-AAAA-AAAA-00C04F79EFBC}") = "projectname", "directoryname/projectname.csproj", "{5D5A753D-AAAA-AAAA-AAAA-C535851E8DC8}"
It seems to work.
Could this have been all I needed to change? I have the feeling that I missed something.
View 2 Replies
Aug 27, 2010
I have a session criteria statement (Fluent NHibernate) that does not seem to filter the child collection even though I have Expressions/Restrictions defined.
ICriteria criteria = session.CreateCriteria(typeof(MyClass));
criteria.CreateAlias("MyCollection", "MC");
criteria.Add(Restriction.Eq("MC.Property", value));
IList<MyClass> list = criteria.List<MyClass>();
This returns all the objects of type MyClass that have MyCollection.Property = value, however MyCollection is not filtered to MyCollection.Property = value
It seems like only the Root objects get filtered.
View 2 Replies
Dec 3, 2010
I have a master page. This is where I put my ScriptManager control.I have a nested master page within the master page.I have a content page within the nested master page. This content page needs to register a Postback control with the ScriptManager, but I can't figure out how to access the ScriptManager. Both Master.FindControl() and Master.Master.FindControl() always return null. I also attempted to use a strongly typed master page, but like all controls, the ScriptManager is protected and thus inaccessible from the content page. How can I access the ScriptManager?
View 2 Replies