473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Menu Item - Problem - Help!

AJ
Hi,

I'm trying to customize the Menu navigation control so that the the static
items have two lines. The first line will be the text (for example "About
Us"), and the second line will be a short description. Also, I have a method
in my class that accepts a string and returns the description required.

Here is what I have on the aspx file:

<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1">
<DynamicItemTemplate>
<%# Eval("Text") %><br />
</DynamicItemTemplate>
<StaticItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Text")
%>'></asp:Label>
<br />
<asp:Label ID="Label2" runat="server"
Text= '<%# GetDescriptionFromTitle(Eval("Text"))
%>'></asp:Label>
</StaticItemTemplate>
</asp:Menu>

As you can see above, the Static Item's second line (Label2) calls the
GetDescriptionFromTitle method. However, the problem I'm facing is that I
can't get it to accept the Eval("Text") as the parameter to this method.

The errors I recieve are (they point to the aspx file):

Error 1 The best overloaded method match for
'_Default.GetDescriptionFromTitle(string)' has some invalid arguments
Error 2 Argument '1': cannot convert from 'object' to 'string'

Any idea what I'm doing wrong?

Appreciate any help or pointers.

Thanks,

AJ

Aug 9 '08 #1
2 1553
On 9 Aug, 07:51, "AJ" <nore...@hotmail.comwrote:
Hi,

I'm trying to customize the Menu navigation control so that the the static
items have two lines. The first line will be the text (for example "About
Us"), and the second line will be a short description. Also, I have a method
in my class that accepts a string and returns the description required.

Here is what I have on the aspx file:

<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1">
<DynamicItemTemplate>
<%# Eval("Text") %><br />
</DynamicItemTemplate>
* * <StaticItemTemplate>
* * * * <asp:Label ID="Label1" runat="server" Text='<%# Eval("Text")
%>'></asp:Label>
* * * * <br />
* * * * <asp:Label ID="Label2" runat="server"
* * * * * * Text= '<%# GetDescriptionFromTitle(Eval("Text"))
%>'></asp:Label>
* * </StaticItemTemplate>
</asp:Menu>

As you can see above, the Static Item's second line (Label2) calls the
GetDescriptionFromTitle method. However, the problem I'm facing is that I
can't get it to accept the Eval("Text") as the parameter to this method.

The errors I recieve are (they point to the aspx file):

Error 1 The best overloaded method match for
'_Default.GetDescriptionFromTitle(string)' has some invalid arguments
Error 2 Argument '1': cannot convert from 'object' to 'string'

Any idea what I'm doing wrong?

Appreciate any help or pointers.

Thanks,

AJ
Hi

Try this:

Text= '<%# GetDescriptionFromTitle(Eval("Text").ToString()) %>'></
asp:Label>

The problem is that the Eval() function returns an object. When it is
bound to the Text property of a Control the DataBinder does the
conversion. In your case it is being supplied as a parameter to a
function that expects a string object so you have to do the conversion
in your code.

Aug 9 '08 #2
AJ
Hi Stan,

Thanks for the help- that worked!

AJ

"Stan" <go********@philhall.netwrote in message
news:ef**********************************@26g2000h sk.googlegroups.com...
On 9 Aug, 07:51, "AJ" <nore...@hotmail.comwrote:
Hi,

I'm trying to customize the Menu navigation control so that the the static
items have two lines. The first line will be the text (for example "About
Us"), and the second line will be a short description. Also, I have a
method
in my class that accepts a string and returns the description required.

Here is what I have on the aspx file:

<asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1">
<DynamicItemTemplate>
<%# Eval("Text") %><br />
</DynamicItemTemplate>
<StaticItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Text")
%>'></asp:Label>
<br />
<asp:Label ID="Label2" runat="server"
Text= '<%# GetDescriptionFromTitle(Eval("Text"))
%>'></asp:Label>
</StaticItemTemplate>
</asp:Menu>

As you can see above, the Static Item's second line (Label2) calls the
GetDescriptionFromTitle method. However, the problem I'm facing is that I
can't get it to accept the Eval("Text") as the parameter to this method.

The errors I recieve are (they point to the aspx file):

Error 1 The best overloaded method match for
'_Default.GetDescriptionFromTitle(string)' has some invalid arguments
Error 2 Argument '1': cannot convert from 'object' to 'string'

Any idea what I'm doing wrong?

Appreciate any help or pointers.

Thanks,

AJ
Hi

Try this:

Text= '<%# GetDescriptionFromTitle(Eval("Text").ToString()) %>'></
asp:Label>

The problem is that the Eval() function returns an object. When it is
bound to the Text property of a Control the DataBinder does the
conversion. In your case it is being supplied as a parameter to a
function that expects a string object so you have to do the conversion
in your code.

Aug 9 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mohit Gupta | last post by:
Hi all, Lately I have been working on an application in VB .net CF for Pocket PC device. I have a small question about Context Menu. When I try to close the window after context menu is poped...
2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
16
by: Jay | last post by:
I've been using Travis's Expanding Menu (http://www.squidfingers.com/code/dhtml/expandingmenu/) for a site i'm working on. The problem is I need to add some functionality to it. I need the the...
0
by: nail | last post by:
Hi. I have this xml file: <menu> <header caption="File"> <item header="File" caption="New File"></item> <item header="File" caption="Open File"></item> <item header="File" caption="Close...
10
by: tmaster | last post by:
When I try to dynamically add a second sub menu item to this ContextMenu item, I get an error 'Specified argument was out of the range of valid values'. Private Sub mnuTopics_Show_Select(ByVal...
4
by: Bob Homes | last post by:
In VB6, I used a system, which I loved, whereby I assigned a "helpId" to each menu item; that way, you could rest the cursor on the item (without actually running it) and then press F1 to get...
1
by: bruce628 | last post by:
I want to use SWT Label and popmenu to construct a menubar ,and the effect of this menubar is same to the menubar in SWT.When click the Label,it should be highlighted and popmenu shows.The issue is...
0
by: hitencontractor | last post by:
I am working on .NET Version 2003 making an SDI application that calls MS Excel 2003. I added a menu item called "MyApp Help" in the end of the menu bar to show Help-> About. The application...
2
by: dharmbhav | last post by:
Hello all, I am trying to develop a roll-over menu effect on a page. It works fine with all other browsers except IE6. Can some one please help me? HTML: <div class="menu-item-wrap">...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.