Web Forms :: Menu Item-subitem Population From Database?

Jan 13, 2010

I am trying to populate menu from database in asp.net 3.5 but as i am new to this technology i really don't know what is the exact way. I tried to find out on web but i found nothing useful for me.

I am developing site for bookstore.First i want to populate departments and then in department, their categories as subitem.

I have both the tables in database.

I tried following code but it is giving me an erroe on relation code line

This constraint cannot be enabled as not all values have corresponding parent values.

All departments dont have categories.

code :

DataSet DepartmentData = new DataSet();
DataTable Department = CatalogAccess.GetDepartments();
DataTable Categories = CatalogAccess.GetCategories();
DepartmentData.Tables.Add(Department);
DepartmentData.Tables.Add(Categories);
DepartmentData.Relations.Add("Children", DepartmentData.Tables[0].Columns["DepartmentId"], DepartmentData.Tables[1].Columns["CategoryId"]);
foreach (DataRow item in DepartmentData.Tables["Department"].Rows)
{
MenuItem DepartmentItem = new MenuItem((string)item["Name"]);
DepartmentItem.ChildItems.Add(DepartmentItem);
foreach (DataRow childItem in item.GetChildRows("Children"))
{
MenuItem childrenItem = new MenuItem((string)childItem["Name"]);
DepartmentItem.ChildItems.Add(childrenItem);
}
}
Departments.DataBind();

and how to add navigation url too!

I can use any other logic but i want to know the better way to code this from expert.

View 12 Replies


Similar Messages:

Web Forms :: How To Show Menu SubItem Whenever Mouse Move On It

Aug 17, 2010

I made a menu control in my ASP.Net page. I have added child items to it. I want that whenever I move mouse on this menu control. It should show me child objects. Just like when ever we put mouse on some control the tooltipText is shown. I've read that their is some hover property, but I don't know how to implement it.

how to do it, as I am new to ASP.Net development.

View 7 Replies

Javascript - Hide Menu Item Or Dropdown Menu Item?

Aug 31, 2010

I have dropdown menu item ("pin this site") that i need to hide it or hide menu item itself ("My Network").

When I saw viewsource on page, I got below code.

<a class="zz1_TopNavigationMenu_1 ms-topnav zz1_TopNavigationMenu_3
ms-topnavselected zz1_TopNavigationMenu_9" href="http://mynetworkqa.spe.org"
style="border-style:none;font-size:1em;">My Network</a>
<a class="zz1_TopNavigationMenu_1 ms-topNavFlyOuts zz1_TopNavigationMenu_6"
href="javascript:__doPostBack(,
'ctl00$PlaceHolderTopNavBar$PlaceHolderHorizontalNav$topSiteMap''Pin')"
style="border-style:none;font-size:1em;">Pin this site</a>

How can I hide menu item?

View 1 Replies

Web Forms :: How To Build A Menu And Each Item Of The Menu Has An Image As Background

Apr 19, 2010

I am need to build a menu and each item of the menu has an image as background knowing that i depend on sitemap to build the menu i used

[Code]....

where menuitem is in a css sheet

[Code]....

it display the image but in the wrong place?

View 1 Replies

Web Forms :: Menu Collapses Automatically When Click On A Menu Item?

Feb 21, 2011

i have a menu which is collapses as a default. This is done by following query.

[Code]....

Now, the problem is, whenever i click on any menu item by expanding the menu, the item page opens but the menu collapses again. I want to let the menu remain as expanded although a menu item is clicked. i.e. menu shouldn't refresh when a menu item is clicked.

View 6 Replies

Web Forms :: Menu Item Click Event For Menu Control

May 7, 2015

Sitemap & Menu:

<asp:SiteMapDataSource ID="Menu" runat="server" ShowStartingNode="false" />
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" OnMenuItemDataBound="OnMenuItemDataBound" DataSourceID="Menu" >
<LevelMenuItemStyles>
<asp:MenuItemStyle CssClass="Menu" />
<asp:MenuItemStyle CssClass="Level" />
</LevelMenuItemStyles>
</asp:Menu>
<siteMapNode url="javascript:Logout" title="Logout" description="Logout" roles="*">
<siteMapNode title="Logout" description="Logout"></siteMapNode>
</siteMapNode>

I want OnClick event instead of navigation .

View 1 Replies

Web Forms :: Menu Control Click Event Not Firing / How To Pass The Selected Menu Item Text To The Other Page

Jan 10, 2011

I am using frames in my webpage.in one of the frames i have a menu control whose items are database driven.when click on the menu item, i want another page to be displayed in other frame.

now i want to pass the the selected menu item text to the other page using session variable which is in the menu item click event method.but the thing is when i click on the menu item, the click event is not firing.

is there any better way to pass the selected menu item text to the other page?

View 1 Replies

Web Forms :: Finding Menu Item From Menu Control?

Apr 15, 2010

I am working with asp.net 2.0 I have 1 problem Regarding Menu Control I used menu control in Master page. Now I have to find out Menu Item from Menu control depending on Condition. how to do that on server and Client side.

My code:

<asp:Menu runat="server" Orientation="Horizontal">
<StaticMenuItemStyle CssClass="jobTabNormal" />
<StaticSelectedStyle CssClass="jobTabSelected" />
<DynamicHoverStyle CssClass="jobTabHover" Font-Bold="true" />
<DynamicMenuStyle />
<DynamicSelectedStyle CssClass="jobTabDynamicSelected" />
<Items>
<asp:MenuItem Text="Job Details" Selected="true" NavigateUrl="#" Enabled="true">
</asp:MenuItem>
<asp:MenuItem Text="Cargos" Enabled="false" NavigateUrl="~/Pages/cargoDetails.aspx">
</asp:MenuItem>.......

View 3 Replies

Web Forms :: How To Remove Menu Item Or Sub Item By Value

Sep 20, 2010

I have an asp.net menu in which i have to let some nodes visible or invisible base on some logic.I know i can find value by item but i wnated to FindItemByValue of my asp.net menu.Could it be possible?

View 3 Replies

C# - How To Pass Command Argument While Selecting A Menu Item In System.Web.UI.WebControls.Menu

Feb 2, 2011

I have a Menu. When user clicks on the menu , I need to pass a command argument. How is that done ?

This is the code for

[code]....

View 2 Replies

AJAX :: How To Highlight Menu Item Of Menu Control For Current Page

May 7, 2015

How to center the menuitems and highlight the selected menuitem in menu control in asp.net?

<asp:Menu ID="maspageMenu" runat="server" BackColor="#2D2D30" Width="100%" DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="1.4em" Font-Strikeout="True" Font-Underline="True" ForeColor="#009933" Orientation="Horizontal" StaticSubMenuIndent="10px" BorderStyle="Groove">
<DynamicHoverStyle BackColor="#18624F" ForeColor="White" />
<DynamicMenuItemStyle BackColor="White" HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicMenuStyle BackColor="White" BorderStyle="Double" />

[CODE]...

View 1 Replies

Hide The Menu Item On Page Load And Show The Item After The Event Is Triggered?

Mar 24, 2011

I am using aspnet menu control and i want to hide the item initially on page load and show the item after an event is trigger say button lick event Can any one give me an example?

View 6 Replies

Web Forms :: DropDownList Selected Item Is Lost And Default Item Is Inserted In Database On Button Click

Jul 16, 2012

I bind dropdownlist in my page

protected void Page_Load(object sender, EventArgs e) {
BindDropDownList(DDL1, "city1", "name", "ID");
DDL1.Items.Insert(0, new ListItem("select city", "0"));
}

And SP

LTER procedure [dbo].[city1]
as
begin
select id,Name
from city
end

And design code

 <asp:DropDownList ID="DDL2" runat="server" CssClass="daddsd">
</asp:DropDownList>

And here is imagebutton code that when click on it update data into table

protected void ImageButton_Click1(object sender, ImageClickEventArgs e) {
string data = Server.UrlDecode(Request.QueryString["BehCode2"]);
SqlCommand _cmd = new SqlCommand("insertinfo", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
_cn.Open();

[Code] ....

Here when i click on button it insert all data into table but it didn't insert my selected item from dropdownlist it insert select city that i define in page_load

 DDL1.Items.Insert(0, new ListItem("select city", "0"));

And when i delete this code from page load it insert in table first row of my table it didn't insert my selected item from dropdown list.

View 1 Replies

Web Forms :: Menu Item Highlighting?

Sep 22, 2010

I have a menu bound to sitemapDatasource and that has 4 independent items with an empty root node as explained in

http://forums.asp.net/t/1176226.aspx

<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" DataSourceID="menu_SiteMapDataSource"

View 2 Replies

Web Forms :: Displaying Item In Iframe Using Menu

Jan 29, 2010

I want to display page in IFrame when you click on menu item. This is how i am writing the code for it.

[code]...

But its opening the page in new window instead of the given Target of Iframe.

View 3 Replies

Web Forms :: Changing Style Of Each Menu Item?

Feb 14, 2010

I want to change each items color in the asp menu control while the menu is generating dynamically from a database.

i.e. 1st item's background color is yellow and 2nd item's background color is red and so on.

View 2 Replies

Web Forms :: How To Menu Selected Item Hilight

Mar 2, 2011

i am using asp:menu for showing the menus in masterpage. If i click the menu item 1, the corresponding page is loading in the content page. I need that the selected Menu item should be highlighted by some color.

[code]....

View 2 Replies

Web Forms :: How To Highlight The Selected Menu Item

Aug 12, 2010

I have one asp leftmenu control in my project.when I select one menu item of menu control that Should be highlight.

how to highlight the selected asp menu item?

View 8 Replies

Web Forms :: Set The Navigateurl For Menu Item In Code Behind?

May 27, 2010

how to set the navigateurl for menu item in code behind .

MenuItem MainMenu = new MenuItem();

i have to set that below code for main menu at dynamically.

NavigateUrl="javascript:navigatetopage();"
function navigatetopage() {
if (confirm("Are you sure want to move")) {
// window.location = "test.aspx";
return true;
}
}

View 7 Replies

Web Forms :: A Different Panel Interface For Each Menu Item?

Mar 7, 2010

Lets say i got "View inbox", "View My Product", "My Profile" on top as the main menu in the admin control panel page

I want to do like this,

when user click on View inbox, the center of the content is to show a view message page, and on the left hand side theres a column showing the related function of View inbox, like "View mesage", "Write new message", "Send message" and etc.

Then when admin click on View My Product, the panel will change to a list of function of "All my products", "Add new products", and so on...

Is there any way i can do like this where each diff menu item change the panel according to the related menu?

Or must i duplicate the panels to each of the page that i need to use?

View 2 Replies

Web Forms :: Select Menu Item Outside The Text?

Jan 22, 2010

I have an <asp:Menu> object on my webpage and it works but it has a very minor shortcoming that is very irritating.

Currently, the menu item is activated when the user clicks on the TEXT of the menu item (Home for example). However, the menu item does not allow me to click on the menu item when I put the mouse over the rectangle which the menu item is in but not on the text.

So if I click on the WORD Home, it works.

When I attempt to click right next to the word HOME, it does not work. I know that I am in the menu item rectangle because I change the background color when hovering over it.

Is there a way to have the menu be active when the mouse is anywhere in the menu item?

Or am I limited to only being able to click on the menu item hyperlink ONLY?

View 2 Replies

Web Forms :: Setting Menu Selected Item From Code Behind?

Nov 10, 2010

I have a master page (Site.master) with a navigation menu linked to a datasource (Master.sitemap). I have a nested master page that has another navigation menu. For any item clicked in this nested navigation menu, I want a particular menu item in the Site.master navigation menu to be selected.

Here's my Site.master menu:
[Code]....

In my Site.master.cs I have this:
[Code]....

In the nested master page, Products.master I have this:
[Code]....

In the Products.master.cs file I try to change the selected item.
[Code]....

The master navigation and products navigation menus work just fine by themselves. But when I've tried to set the selected item of the master menu in the Page_Load above, I can't seem to access it. What I've found in trying to do this is the NavigationMenu seems to be uninitialized. The menu Items list is empty. What am I missing here? Why are there no menuItems in the Master.NavigationMenu control?

View 2 Replies

Web Forms :: Menu Top Level Selected Item Style?

Aug 22, 2010

I want to apply a css class to the level 1 menu item (parent) when it or any or it's children are selected. I've looked at MSDN documentation and any number of examples and walkthroughs but I haven't come up with a way of managing this. I was thinking something like this might work but the style is not being applied to the parent. To further complicate matters, if I try to apply a css style to StaticSelectedStyle it doesn't pick it up at all.

Menu Markup:
<StaticSelectedStyle Font-Bold="True" ForeColor="#3333CC" />
Code Behind:
protected void MenuItemClick_NavMenu(Object sender, MenuEventArgs e)
{menuItem parentItem = e.Item.Parent;
if (parentItem != null)
{
parentItem.Selected = true;
}

View 2 Replies

Web Forms :: Assign Shortcut Keys For Menu Item

Dec 29, 2010

How to assign shortcut keys for menu item of asp.net menu control e.g. i have one menu which open like this Trouble Ticket -->Trouble Ticket --> Add or Update or Edit so i wnat when i will press CTRL + TA for Add , CTRL + TU for update , CTRL + TE for edit.

View 2 Replies

Web Forms :: Menu Control ... Cannot Select Item At 4th Level

Nov 8, 2010

I have this control on a page. The selections are static. The "maximumlevels" is set to 6. When I click on an item at the 4th level, I can see the postback occur but the "click" event doesn't fire! I'm totally baffeled. I've tested this in the Page Load event. At this point the PRIOR menu selected value shows. On the next menu_click, the previous selection shows. The first menu item is "selected" and has a value of "Overview". The fourth level item has a value of "Child". No matter how many times I selected that item, my check in the Page Load shows the value to be "Overview". I've tested the 3rd level items and on click, I can see the prior menu item value. When I click a 4th level item, the value never changes from the last 3rd level or higher item selected.

View 7 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved