Displaying a null decimal value as a string

  • Thread starter Microsoft News Group
  • Start date
M

Microsoft News Group

I am trying to make a column which is decimal format, convert nulls to a
certain string such as "No Max".
This is for a price range, and if they do not put a value in, a null value
is put in place, but displays "No Max", but if it is not null, then it would
display the decimal value in place. How can I do this in the gridview.
 
G

Guest

Not quite sure but a suggestion:

Are you talking about nulll in SQL column? In this case the SQLType.DBNull
is converted to 0 in a bound field. If you convert the bound field to a
template field you might be able to use a Label or TextBox control and
convert the 0 value in the OnPreRender event. This would presumably would
have ReadOnly set to true.

You might also be able to do something like:

<%#Eval("PriceRange")==DBNull.Value?"NoMax":Eval("PriceRange")%>

although I'm not sure about using the Eval on the right side of the
conditional expression.

I think most developers would encourage you to use ObjectDataSource and do
the retrieval and conversion in the business object
 

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

Top