在运行时设置 DataGridView 上的 DataFormatString?
是否可以在运行时设置 ASP.NET DataGridView 中的列或单元格的 DataFormatString 属性?
Is it possible to set the DataFormatString property of a column or cell in an ASP.NET DataGridView at runtime?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这应该有效。
通过 找到链接
This should work.
Found via Link
据我所知,您可能想尝试在 RowDataBound 事件上执行列格式,尽管可能会降低性能。
如果有人可以提供更简单的方法,我会很高兴。
Not that I know of, you might want to try peforming the column formatting on RowDataBound event though might have some performance degrade.
Will be glad if someone can provide a simpler method.
似乎没有办法设置 DataFormatString 属性。 我最终将数据源绑定到表,然后遍历所有单元格并手动格式化它们:
此方法非常适合我。 不确定它如何扩展大型数据集,尽管我猜测它会很好。
There doesn't seem to be a way to set the DataFormatString property. I have ended up binding the datasource to the table and then going through all the cells and formatting them manually:
This method works perfectly for me. Not sure how it would scale up with a large dataset although my guess is it would be fine.