GridView is trimming leading spaces. Can I stop that?

女生的网名这么多〃 提交于 2019-12-24 16:28:00

问题


The GridView in ASP.NET 2.0 is trimming the leading spaces from data coming from a SQLServer database. I have yet to find a way to keep it from doing that. The data in this particular view is being edited to remove such spaces, but only upon editing the row can any leading spaces be seen, meaning, at present, each row will have to be touched. With 12,000+ rows, that's a little much.

What little I've found on Google has mainly be concerned with trimming leading spaces. Is there a way to force GridView to show the data exactly as it is in the database, leading spaces and all?

Thanks in advance for any help.

Michael


回答1:


How about, when you bind your data, replace all '' characters with ' '. You can do this with a OnRowDataBound event or through DataFormatString (here's a relevant example).



来源:https://stackoverflow.com/questions/2517434/gridview-is-trimming-leading-spaces-can-i-stop-that

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!