Datagrid formatting dropping leading blanks

T

tfs

I am reading into a datagrid and can't seem to get the "execution
time" column (the 3rd column) to move to the right.

My problem is that the last character in the 2nd column is right up
against the end of the column and the 3rd column is too close and
confusing. So I was trying to move the data in the 3rd column over a
few spaces.

So I did the following:

SELECT tableName,startTime,executionTime = replicate(' ',6) +
convert(char(10),Round((executionTime /
60),2)),numRecordsCopied,numRecordsInError FROM VDW..xferstats

This works fine in the SQL Query in the table view and it does move
the data to the right a few places. When I run this in my web page
with the following datagrid, the text has all the leading spaces
truncated:
<asp:DataGrid AllowPaging="false"
AllowSorting="False"
AutoGenerateColumns="false"
CellPadding="3"
CellSpacing="0"
DataSource="<%# DataSet1.DefaultView %>" ID="DataGrid1"
runat="server"
ShowFooter="false"
ShowHeader="true"
<HeaderStyle HorizontalAlign="center"
BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial,
Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" />
<ItemStyle BackColor="#F2F2F2"
Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller"
/>
<AlternatingItemStyle BackColor="#E5E5E5"
Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller"
/>
<FooterStyle HorizontalAlign="center"
BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial,
Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" />
<PagerStyle BackColor="white"
Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller"
/>
<Columns>
<asp:BoundColumn DataField="tableName"
HeaderText="Table Name"
ReadOnly="true"
Visible="True"/>
<asp:BoundColumn DataField="startTime"
HeaderText="Start Time"
ReadOnly="true"
Visible="True"/>
<asp:BoundColumn DataField="executionTime"
HeaderText="Execution Time"
ReadOnly="true"
Visible="True"/>
<asp:BoundColumn DataField="numRecordsCopied"
HeaderText="Processed"
ReadOnly="true"
Visible="True"/>
<asp:BoundColumn DataField="numRecordsInError"
HeaderText="Errors"
ReadOnly="true"
Visible="True"/>
</Columns>
</asp:DataGrid>

If I change the replicate(' ',6) to replicate('0',6), it shows the
leading 0's fine.

How do I get this to work, if it is even possible?

Thanks,

Tom
 
J

John Saunders

tfs said:
I am reading into a datagrid and can't seem to get the "execution
time" column (the 3rd column) to move to the right.

My problem is that the last character in the 2nd column is right up
against the end of the column and the 3rd column is too close and
confusing. So I was trying to move the data in the 3rd column over a
few spaces.

HTML ignores spaces. If you need to space things that way, you need to use
"&nbsp;" (non-breaking space) instead.

You can also try playing with the styles on the column. In particular, you
can set the width of the column.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top