Try
litDilCurrentYesNo.Text = ((int)dtrDilemmas
["CurrentYes"]).Tostring() + "votes yes and " + ((int)
dtrDilemmas["CurrentNo"]).Tostring() + " votes no";
HTH,
Elton Wang
>-----Original Message-----
>Hello,
>
>I have an ASP.NET page where I am grabbing an
SqlDataReader and using it
>to populate some controls on the form. Amongst the fields
pulled out of
>the table are two integer fields, which I am trying to
cast as strings
>so they can be displayed in a Literal control.
>
>I am using the following code (heavily edited for
clarity) ...
>
> if (dtrDilemmas.Read()) {
> litDilCurrentYesNo.Text = (String)dtrDilemmas
["CurrentYes"] + "
>votes yes and " + (String)dtrDilemmas["CurrentNo"] + "
votes no";
> }
>
>where dtrDilemmas is the SqlDataReader that contains just
one record. In
>that record are two fields, CurrentYes and CurrentNo,
which are both
>integers. I have other (varchar) fields which I can use
just fine. When
>it hits the line shown above, I get the error "specified
cast is not
>valid".
>
>Anyone any idea why not and how I fix it? TIA
>
>--
>Alan Silver
>(anything added below this line is nothing to do with me)
>.
>