[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

(crjunk)

1/21/2003 10:10:00 PM

How do I trim the trailing spaces for one of my columns of data in my
datagrid? I need to remove the trailing spaces for the dollar amount
that I am trying to align right. Is this done on the HTML side or the
cobe behind page?


Here is what I have so far on the HTML part of my web form:

<asp:BoundColumn DataField="total_gran" HeaderText="Total Grant"
FooterStyle-HorizontalAlign = "Right">
<HeaderStyle Font-Bold="True" VerticalAlign="Top"></HeaderStyle>
</asp:BoundColumn>



Thanks in advance!
1 Answer

(Scott Mitchell [MVP])

1/21/2003 10:10:00 PM

0

crjunk@earthlink.net (crjunk) wrote in message news:<e45e90aa.0301161406.31ffc2c5@posting.google.com>...
> How do I trim the trailing spaces for one of my columns of data in my
> datagrid? I need to remove the trailing spaces for the dollar amount
> that I am trying to align right. Is this done on the HTML side or the
> cobe behind page?

This is done on the code-behind side.

> <asp:BoundColumn DataField="total_gran" HeaderText="Total Grant"
> FooterStyle-HorizontalAlign = "Right">
> <HeaderStyle Font-Bold="True" VerticalAlign="Top"></HeaderStyle>
> </asp:BoundColumn>

Use a TemplateColumn instead of a BoundColumn, like so:

<asp:Template HeaderText="Total Grant" FooterStyle-HorizontalAlign =
"Right">
<ItemTemplate>
<%# ((String) DataBinder.Eval(Container.DataItem,
"total_gran")).Trim() %>
</ItemTemplate>

<HeaderStyle Font-Bold="True" VerticalAlign="Top"></HeaderStyle>
</asp:TemplateColumn>

(The above is C# syntax, you would have to use CType() to convert the
Object returned by DataBinder.Eval to a String in VB.NET)

I invite you to read these two articles, as they will take you closer
to your destination:

Creating a Custom DataGrid Column Class
http://aspnet.4guysfromrolla.com/articles/100...

An Extensive Examination of the DataGrid Web Control - Part 5
http://aspnet.4guysfromrolla.com/articles/061...

Happy Programming!

--


Scott Mitchell [MVP]
http://www.4GuysFro...
http://www.ASPMessag...
http://www.A...

* When you think ASP, think 4GuysFromRolla.com!