|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem with spaces in values of the DataTextField property of datagrid controlI am using a datagrid control to display the values from a database table. I have used a Button Column with the DataTextField Column set to the field in the db table, from where I need to populate values. It is basically a Report Name. The problem is that if the Report name contains spaces, the same is rendered on the Datagrid column without spaces. In other words, if I saved a report name as "joe black" or "joe black" or "joe black", it is always displayed as "joe black" on the grid control. The db table saves the name correctly. Can anyone suggest some way to overcome this problem?? Thanks, Sadhvi M Your problem lies with the way browsers interpret whitespace in HTML.
Most browsers would render 1 space even though there are multiple spaces in the source HTML. A suggestion to preserve spaces is to replace each space in the report name with the html entity. You do the replacement after reading the values out of the database and before doing a databind on the gridview. Another suggestion to preserve spaces is to enclose the report name with the <pre> tag. Andy. chorus_cha***@yahoo.com wrote: Show quoteHide quote > Hi, > > I am using a datagrid control to display the values from a database > table. > > I have used a Button Column with the DataTextField Column set to the > field in the db table, from where I need to populate values. It is > basically a Report Name. > The problem is that if the Report name contains spaces, the same is > rendered on the Datagrid column without spaces. > > In other words, if I saved a report name as "joe black" or "joe > black" or "joe black", it is always displayed as > "joe black" on the grid control. > The db table saves the name correctly. > > Can anyone suggest some way to overcome this problem?? > > Thanks, > Sadhvi M
Wizard control in 2.0 and dynamic items
Passing values to user controls - naughty problem Why it doesn't work? web controls install Can't access webpage's controls from the code-behind file after putting it in a <asp:LoginView/> is this possible? Interrogating cells on current row for GridView Best way to save properties (ie. text) on webcontrols for reloading (asp.net 2.0) CheckBoxList Control column width Treeview Width. |
|||||||||||||||||||||||