Too many characters in character literal... not using char!

  • Thread starter Thread starter PK
  • Start date Start date
P

PK

I'm getting this error message when using a conditional in a repeater:

Compiler Error Message: CS1012: Too many characters in character
literal

According to MSDN, this message means that I'm trying to initialize a
char constant with more than one character, like:

char a = 'xx'

It's disagreeing with my use of '999999999'. I think I'm using it in
a string comparison, but apparently I'm wrong. By the way, column1 is
defined as varchar, I don't know if that matters...

Has anyone else run into this problem?

Thanks!

PK




<td>
<%# ( DataBinder.Eval(Container,"DataItem.column1") ==
'999999999') ?
DataBinder.Eval(Container,"DataItem.column2") :
DataBinder.Eval(Container,"DataItem.column1") %>
</td>
 
You have single quotes around your string, not double quotes. Single quotes
are for characters - but that would mean only one character in the single
quotes, and you have more then that.
 
Solved my own problem... Had to cast database field as a string (it
was reading as an object, whatever that means).

<%#( ( Convert.ToString(DataBinder.Eval(Container,"DataItem.column1"))
== "999999999") ?
(DataBinder.Eval(Container,"DataItem.column2")) :
(DataBinder.Eval(Container,"DataItem.column1")) )%>
 
Back
Top