1
我使用DataFormatString通過使用DataFormatString =「{0:c}」爲我的detailsview將價格boundfield轉換爲貨幣格式。
但是,它好像是數據庫中的值爲空或空值,而不是在我的詳細信息視圖中顯示空白,DataFormatString使其顯示爲0.00美元。我試圖設置NullDisplayText =「」,但它似乎不工作。
任何想法如何做到這一點?我是否需要使用ItemTemplate?
這是我如何獲得在.aspx
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:TestString %>"
SelectCommand="SELECT [Price] FROM [DataBase] WHERE ([ID] = @ID)">
這個數據是結合數據的代碼:
<asp:BoundField DataField="Price" HeaderText="Price:" SortExpression="Price"
DataFormatString="{0:c}" NullDisplayText="" />
您是如何獲取數據的?如果值爲空或爲空,您是否可以不使用存儲過程返回「0」? – Oded
已更新我的問題,顯示我的數據獲取位置 – Kevin
看起來更好的查詢可能有所幫助(請查看[CASE](http://msdn.microsoft.com/en-gb/library/ms181765.aspx))。 – Oded