2015-11-19 11:38:10
存在问题:
gridview需要对小数位数进行控制
解决方案:
前后台分别加以控制
前台:
<dxwgv:GridViewDataTextColumn Caption="账户余额" FieldName="YE" VisibleIndex="5">
<CellStyle HorizontalAlign="Right">
</CellStyle>
<DataItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%#ConvertFormat(Eval("YE").ToString())%>'></asp:Label>
</DataItemTemplate>
</dxwgv:GridViewDataTextColumn>
后台:
/// <summary>
/// 将数字保留两位
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public string ConvertFormat(string str)
{
string result = "";
result = Convert.ToDecimal(str.ToString()).ToString("0.00");
return result;
}