1 string .Formart();2 sql case;3 datagrid显示格式控制;4 String.Format举例(C#);格式控制style="MARGIN: 0px"
1 String cmdText= String.Format("select * from H_OutContract where HourseID='{0}' and OutContractEndTime>= '{1}'"
,h_OutContract.HourseID,h_OutContract.OutContractBeginTime);
2 string cmdText="SELECT OutContractID, HourseID, OutContractNo, OutContractBeginTime, OutContractEndTime, RenterJianYiMoney, RenterMoney, RebateMoney, HourseName, BankNo, BankName, OutContractByUser, OutContractByAdmin, IsAuditing, IsRenter, OutContractInfo, "+
" case IsAuditing when 1 then '已审核' "+
" when 0 then '设置' "+
" else "+
" '否' end as IsAud"+
" FROM H_OutContract";
3 {d:D} GridView,datagrid 显示格式控制
在设置GridView数据绑定控件的模版列时,总要设置显示的格式,这里是我查询一些资料后统计出来的。还有一个常规的选项是用数据库中默认的格式显示。
5 HTML 格式近制;
<body style="MARGIN: 0px" MS_POSITIONING="GridLayout">
,h_OutContract.HourseID,h_OutContract.OutContractBeginTime);
2 string cmdText="SELECT OutContractID, HourseID, OutContractNo, OutContractBeginTime, OutContractEndTime, RenterJianYiMoney, RenterMoney, RebateMoney, HourseName, BankNo, BankName, OutContractByUser, OutContractByAdmin, IsAuditing, IsRenter, OutContractInfo, "+
" case IsAuditing when 1 then '已审核' "+
" when 0 then '设置' "+
" else "+
" '否' end as IsAud"+
" FROM H_OutContract";
3 {d:D} GridView,datagrid 显示格式控制
形式 | 语法 | 结果 | 注释 |
数字 | {0:N2} | 12.36 | |
数字 | {0:N0} | 13 | |
货币 | {0:c2} | $12.36 | |
货币 | {0:c4} | $12.3656 | |
货币 | "¥{0:N2}" | ¥12.36 | |
科学计数法 | {0:E3} | 1.23E+001 | |
百分数 | {0:P} | 12.25% | P and p present the same. |
日期 | {0:D} | 2006年11月25日 | |
日期 | {0:d} | 2006-11-25 | |
日期 | {0:f} | 2006年11月25日 10:30 | |
日期 | {0:F} | 2006年11月25日 10:30:00 | |
日期 | {0:s} | 2006-11-26 10:30:00 | |
时间 | {0:T} | 10:30:00 |
4 String.Format举例(C#)
2007-04-13 10:01
stringstr1 =string.Format("{0:N1}",56789); //result: 56,789.0 |
5 HTML 格式近制;
<body style="MARGIN: 0px" MS_POSITIONING="GridLayout">