If/Then

  • Thread starter Thread starter Laura K
  • Start date Start date
L

Laura K

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
 
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);
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top