0

I have a numeric value like this in my db,

14192555.00

when i get it and put it in text box and convert it in to string it results in,

this.txtPriorNYSDOTRating.Text = ds.Tables[0].Rows[0]["Fact2A_PriorNYSDOTPerfRatingScore"].ToString();
14192555.0000

for it formatting i also tried,

this.txtPriorNYSDOTRating.Text = ds.Tables[0].Rows[0]["Fact2A_PriorNYSDOTPerfRatingScore"].ToString("0.####");

it result in error "no overload for method string"

Hopes for your suggestion thanks in advance

EDITED:

i have date in database like,

2010-10-19 00:00:00.000

i get it like,

10/19/2010 12:00:00 AM

my code is,

this.txtDesignatedDate.Text =Convert.ToDateTime(ds.Tables[0].Rows[0]["DesignatedDate"]).ToString();

how to format it to get only `"10/19/2010"

Hopes for your reply

4

1 回答 1

4

您需要将其转换为双精度,然后应用该格式。

double d = Convert.ToDouble(ds.Tables[0].Rows[0]["Fact2A_PriorNYSDOTPerfRatingScore"]);
this.txtPriorNYSDOTRating.Text = d.ToString("0.####");

目前它是object类型的,并且不会暴露ToString带有格式参数的重载。

于 2013-05-16T07:05:52.653 回答