Q: Eval and casting.

Discussion in 'ASP .Net' started by Martin Arvidsson, Visual Systems AB, Apr 4, 2008.

  1. 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, Visual Systems AB, Apr 4, 2008
    #1
    1. Advertising

  2. Martin Arvidsson, Visual Systems AB

    Andrea Zani Guest

    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, Apr 4, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kevin
    Replies:
    11
    Views:
    5,799
    Andrew McDonagh
    Jan 8, 2005
  2. DataBinder.Eval and Eval.

    , Jun 16, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    542
    Karl Seguin [MVP]
    Jun 16, 2006
  3. Wally Barnes
    Replies:
    3
    Views:
    522
    Wally Barnes
    Nov 20, 2008
  4. Sosuke

    Up casting and down casting

    Sosuke, Dec 20, 2009, in forum: C++
    Replies:
    2
    Views:
    560
    James Kanze
    Dec 20, 2009
  5. Liang Wang
    Replies:
    8
    Views:
    129
    Ben Morrow
    Feb 2, 2008
Loading...

Share This Page