开发者

Format a numeric string using a numeric composite format

开发者 https://www.devze.com 2023-01-10 16:39 出处:网络
I\'ve just encountered an interesting problem in a standard BoundField in a GridView.The field is for EmployeeCode, which is purely numeric, but stored in a character column in the database.The DataFo

I've just encountered an interesting problem in a standard BoundField in a GridView. The field is for EmployeeCode, which is purely numeric, but stored in a character column in the database. The DataFormatS开发者_如何学Pythontring="{0:00000}" attribute on the BoundField doesn't work, as I assume that format is only for numeric values.

To work around this, I had to use a TemplateField, and bind the text value using the attribute Text='<%# PadNumericString(Eval("EmployeeCode").ToString(), 5) %>'. Is there no simpler way of doing this?


Try setting HtmlEncode = false on your original BoundField and use your existing dataformatstring.

0

精彩评论

暂无评论...
验证码 换一张
取 消