Advertisement

01.28.2008 at 09:12AM PST, ID: 23116832
[x]
Attachment Details

Formatting numbers in a gridview

Asked by david_evans_work in Visual Studio, Microsoft Excel Spreadsheet Software, Programming for ASP.NET

Tags: , ,

HI, I am using the following code to read an excel spreadsheet into a datagrid. The code works fine but I am left with the values showing, how can I format the results to show only 2 numbers after the decimal and the thousand seperator? (Using VB.NET) :
ColName Q1          Q2          Q3          Q4
1             123.456  45.6897 47.3587  12.5744

 Sub ReadTestData()
        Dim DBConnection = New OleDbConnection( _
                          "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                          "Data Source=" & Server.MapPath("~/excel/" & "7476073472" & ".xls") & ";" & _
                          "Extended Properties=""Excel 8.0;HDR=Yes""")
        DBConnection.Open()
        Dim SQLString As String = "SELECT * FROM [Test$]"
        Dim DBCommand = New OleDbCommand(SQLString, DBConnection)
        Dim DBReader As IDataReader = DBCommand.ExecuteReader()
        GridView9.DataSource = DBReader
        GridView9.DataBind()
        DBReader.Close()
        DBConnection.Close()
    End Sub

thanks in advanceStart Free Trial
[+][-]01.28.2008 at 09:43AM PST, ID: 20761187

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.28.2008 at 09:56AM PST, ID: 20761277

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.28.2008 at 11:48PM PST, ID: 20766018

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.29.2008 at 08:17PM PST, ID: 20774621

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Studio, Microsoft Excel Spreadsheet Software, Programming for ASP.NET
Tags: code, formatting, number
Sign Up Now!
Solution Provided By: needo_jee
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628