If/Then

Discussion in 'ASP .Net' started by Laura K, Aug 10, 2005.

  1. Laura K

    Laura K Guest

    Having trouble making the switch from ASP classis to .NET. I have a table
    cell which contains a color. To get that text I have the following.
    <%# DataBinder.Eval(Container.DataItem, "Color").ToString() %> and out pops
    the color onto the page.

    Now not all items have colors. At this time the space is just blank if there
    is no color. I want to be able to have an NA appear instead. Tried various
    IF/THENs I know what to do in classic. What do I do in .NET. Can
    someone help with a bit of syntax?

    Laura K
     
    Laura K, Aug 10, 2005
    #1
    1. Advertising

  2. Try doing it in the ItemDataBound.

    "Laura K" <> wrote in message
    news:%...
    > Having trouble making the switch from ASP classis to .NET. I have a table
    > cell which contains a color. To get that text I have the following.
    > <%# DataBinder.Eval(Container.DataItem, "Color").ToString() %> and out

    pops
    > the color onto the page.
    >
    > Now not all items have colors. At this time the space is just blank if

    there
    > is no color. I want to be able to have an NA appear instead. Tried

    various
    > IF/THENs I know what to do in classic. What do I do in .NET. Can
    > someone help with a bit of syntax?
    >
    > Laura K
    >
    >
     
    Patrick.O.Ige, Aug 11, 2005
    #2
    1. Advertising

  3. Another method is to call a function

    <%# findColor(DataBinder.Eval(Container.DataItem, "Color").ToString()) %>

    the "findColor" function in code behind would look like

    protected string findColor(string inColor)
    {
    if(inColor.Trim().Length == 0)
    return("NA");

    return(inColor);
    }




    "Laura K" wrote:

    > Having trouble making the switch from ASP classis to .NET. I have a table
    > cell which contains a color. To get that text I have the following.
    > <%# DataBinder.Eval(Container.DataItem, "Color").ToString() %> and out pops
    > the color onto the page.
    >
    > Now not all items have colors. At this time the space is just blank if there
    > is no color. I want to be able to have an NA appear instead. Tried various
    > IF/THENs I know what to do in classic. What do I do in .NET. Can
    > someone help with a bit of syntax?
    >
    > Laura K
    >
    >
    >
     
    =?Utf-8?B?U3JlZWppdGggUmFt?=, Aug 11, 2005
    #3
    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. =?Utf-8?B?TWlrZQ==?=

    greater then / less then

    =?Utf-8?B?TWlrZQ==?=, Nov 4, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,604
    Kevin Spencer
    Nov 4, 2004
  2. JosephByrns

    Slow, then quick then slow

    JosephByrns, Jul 10, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    2,508
    codezilla94
    Nov 13, 2007
  3. Mufasa
    Replies:
    7
    Views:
    426
    Alexey Smirnov
    Sep 4, 2007
  4. Replies:
    0
    Views:
    316
  5. Replies:
    4
    Views:
    552
    cwdjrxyz
    Jan 17, 2006
Loading...

Share This Page