[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

noreply@hotmail.com

8/9/2008 6:51:00 AM

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

2 Answers

Stan

8/9/2008 9:23:00 AM

0

On 9 Aug, 07:51, "AJ" <nore...@hotmail.com> wrote:
> 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.

noreply@hotmail.com

8/9/2008 9:52:00 AM

0

Hi Stan,

Thanks for the help- that worked!

AJ

"Stan" <googlestan@philhall.net> wrote in message
news:efca1577-6854-4d87-8208-ef172568d220@26g2000hsk.googlegroups.com...
On 9 Aug, 07:51, "AJ" <nore...@hotmail.com> wrote:
> 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.