473,472 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Specify Format String For Auto-Generated Datagrid Column?

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.
Nov 18 '05 #1
3 2573
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.)

Nov 18 '05 #2
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
"MSFT" <lu******@online.microsoft.com> escribió en el mensaje
news:c2**************@cpmsftngxa07.phx.gbl...
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.)

Nov 18 '05 #3
Hi Juan,

In this situation, we may change text's format of datagrid cell in its
ItemDataBound. You may refer to follow article as a sample:

http://support.microsoft.com/default...;EN-US;Q313154

In above article, he change some special cell's format. We can apply the
way in the cells we want.

Luke
Microsoft Online Support

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

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Girish | last post by:
Hi Here is the STEPS/METHOD my service provider sends the calling customer numbers captured : Export Method - HTTPS 1. The partner provides Who's Calling with a URL address to direct the data...
2
by: sp | last post by:
Hello Everybody, I need to convert xml that we get from sqlserver For xml auto to my own xml format using asp.net classes. Any ideas and suggestions would be appreciated. Thanks in Advance sp
7
by: Aaron | last post by:
I like some of the auto-formatting features of VB.NET (god help me) but I really prefer to use CSharp (C#) is there any way to get the features of auto-indenting, auto-capitalization, and advanced...
0
by: Ricky Chan | last post by:
I am using DNSQuery API to get computer name from IP address. However, by below sample code, I don't know how to specify the DNS Address for the field (ByVal aipServers As Integer). any idea?...
3
by: Thom | last post by:
I'm trying to use shell to execute an old dos based program. This program takes a binary file and does internal processing and then outputs a text file based on the processing. I am choking on the...
2
by: jeswin12 | last post by:
I used the following script to auto format the phone number field in my form. http://javascript.internet.com/forms/format-phone-number.html The problem with this code is im able to set the...
2
by: Joe | last post by:
Is there a format string to auto convert negative numbers to display in parentheses? For example myInt.ToString("if < 0 (#) else #"). I need to pass a format to another control so I can't check...
1
by: Rasko | last post by:
when i try to insert kind of text to my richtextbox from web (copy/paste) i can do it but after i wanted to update i can't do it . there is an errormessage appears (Input string was not in a correct...
4
by: Paul | last post by:
The title says it all. Is there a speed efficient way of validating that a string contains valid Xml without the overhead of try catch around a load attempt? Thanks in advance.
9
by: Mark G. | last post by:
Good afternoon. I have a "Fixed/2" format applied to a textbox on its property sheet. When I type data in the textbox, it is formatted correctly. But when I update the value programatically by...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.