Eliminating Decimals

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Web Application

I'm showing data in a DataGrid from a SqlDataReader, in my DB the values are
stored without decimals (300,500,8000) but when the SqlDataReader return the
data, it come with decimal (300,0000; 500,0000;80000,0000).

is There a way to format the data returned by the SqlDataReader or to
format the data on the DataGrid in order to eliminate the decimal numbers?

Any Sug
Thks

Kenny
 
String.Format is one option. It is also possible to cast out as an integer
value when you pump the data out of your RDBMS. In addition, you can move to
a DataSet and strongly type the data as integral and avoid the floating point
(although this can bomb on the cast in some instances).

NOTE: The farther down the stack (on the database side) you solve the
problem, the better the perf ... at least in general. Maintainability,
however, is dictated by where you and the other progs feel most comfortable.

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
If you specify the columns in the DataGrid using a <Columns> element you can
control the way that the values are displayed using a format string. For
example:

<Columns>
...other columns here...
<asp:BoundColumn DataField="UnitPrice"
DataFormatString="${0:f2}"
ItemStyle-HorizontalAlign="Right"
HeaderStyle-HorizontalAlign="Right"
HeaderText="Price"/>
...other columns here...
</Columns>
 
thanks
Umm But I'm binding the Grid with the DataReader with no additional code so
I think there must be a way to do the same in the _ItemDataBound event

I´m going to play with this
 
Back
Top