2013-05-16 43 views
0

我在我的分貝這樣的數值,將從數據集中獲取的數字值轉換爲字符串Asp.net c#?

14192555.00 

當我得到它,並把它在文本框,並將其轉換到字符串它導致,

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

它格式化我也試過,

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

它導致錯誤 「no overload for method string

分的希望您的建議感謝提前

編輯:

我在數據庫中,如日期,

2010-10-19 00:00:00.000 

我得到它像,

10/19/2010 12:00:00 AM 

我的代碼,

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

如何格式化只得到`「10/19/2010」

的希望您的回覆

回答

4

你需要將其轉換爲加倍,然後應用格式。

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

目前,它是object型的和不公開ToString超載與格式參數。