开发者

Format a numeric string using a numeric composite format

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜