Q: Eval and casting.

Hi!

I have a webpage with a DataGrid and a codebehind file containing a method
called OrderStatusText

The line in question in the asp page
<ItemTemplate>

<%# OrderStatusText((byte)Eval("OSTATUS")) %>
</ItemTemplate>

I got the message: Specifyed cast not valid when i ran the page

The method looks like

public string OrderStatusText(byte status)
{
do stuff
return stuff
}

Any idea why it's not possible?

I got the cast code from the msdn2 pages.

Regards
Martin
martin.arvidsson [ Fr, 04 April 2008 15:59 ] [ ID #1935401 ]

Re: Q: Eval and casting.

Martin Arvidsson, Visual Systems AB ha scritto:
> The line in question in the asp page
> <ItemTemplate>
>
> <%# OrderStatusText((byte)Eval("OSTATUS")) %>
> </ItemTemplate>
>
>
> Any idea why it's not possible?

You can write:
<%# OrderStatusText(Convert.ToByte(Eval("OSTATUS"))) %>

> Regards
> Martin

Bye
--
AZ
Andrea Zani [ Fr, 04 April 2008 16:40 ] [ ID #1935405 ]
Microsoft » microsoft.public.dotnet.framework.aspnet » Q: Eval and casting.

Vorheriges Thema: Display source in ASPX page for a help site
Nächstes Thema: moving columns in an autogenerated gridview