Specify Format String For Auto-Generated Datagrid Column?

J

Joey Powell

Is it possible to specify a format string for one or more
auto-generated datagrid columns? If so, could someone post an example?
More specifically, I am interested in taking output like 27.0800000
and turning it into 27.08

I have also tried doing this with the underlying SQL statement, but I
can't get it to work that way, either.
 
M

MSFT

Hi Joey,

Thank you for using MSDN Newsgroup. I am Luke and I am review this issue
currently. From your description, you want to format the output in a
datagrid, for example, from 27.0800000 to 27.08. The data is retrieve from
a database.

Regarding the question, if the database is SQL server, I think the easiest
way is doing with the underlying SQL statement, for example:

select CONVERT(decimal(15,2), DecColumn) as DecimalField from Table1

As you the Convert function in SQL server can format the decimal column
with 2 bits scale. We only need to modify the SelectCommand of the
DataAdapter like this.

Hope this help,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
J

Juan Ramon Martinez

Im running into the a very similar situation.

The only difference is that my data does not come from any database
whatsoever. In fact it comes from a variety of files the user can upload, it
is then stored in a collection of objects I designed and finally displayed
in a datagrid. Is there a way to format data in this scenario?

Thanks

Juan Ramon
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top