Hi Guys,

If you have a Text Box which you are putting in the Decimal Places such as "15.50". Then Submitting this to a Access Database then on re-fresh the data shows in the grid view as "15.5". Where abouts should this be modified so that it shows Decimal Places?

Is it on the Access DB Layout and how it's store or should there be come amendment on the code side? It looks like the GridView is removing the trailing '.00's' ??

Many thanks for any help.

Sorry Guys,

Found the answer. Was able to go into the Gridview and change the properies to show 2 Decimal Places..

Thank you anyways.. Hope this helps someone else out!

Click HereAh.. It looks like I spoke to soon guys...

Due to their being a 'Date Format' within the GridView its now coming up with 'N2' instead of the Date.

How can I filter out this column? (Attached Screenshot).

Also Below is the snippet of Code I'm currently using. When a user select the account from the DGV1 it will pull up the corresponding Orders in DGV2 via the ODBC Connection.

  private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            //If the Radio Button is checked the Script between the {} will be run//
            if (radioButton1.Checked == true)
            {
                //Looks at the row Selected in the GridView and then takes the Account Number and Stores in a Int64 called 'Customer ID'//
                DataGridViewRow drow = dataGridView1.SelectedRows[0];
                //Int64 CustomerID = Convert.ToInt64(drow.Cells[0].Value);
                string CustomID = Convert.ToString(drow.Cells[1].Value);


                //Sets the Selected Account and shows inside the Text Boxes on the right-hand side of the screen//
                txtAccRef.Text = dataGridView1.SelectedCells[1].Value.ToString();
                txtAccName.Text = dataGridView1.SelectedCells[2].Value.ToString();
                txtAccAddr1.Text = dataGridView1.SelectedCells[3].Value.ToString();
                txtAccAddr2.Text = dataGridView1.SelectedCells[4].Value.ToString();
                txtAccTown.Text = dataGridView1.SelectedCells[7].Value.ToString();
                txtAccPostCode.Text = dataGridView1.SelectedCells[6].Value.ToString();
                txtAccCounty.Text = dataGridView1.SelectedCells[5].Value.ToString();


                //Message to Test ID has been stored//
                //MessageBox.Show("Customer ID Stored");

                //Creates new versions of the Connection string and Data Set//
                con = new System.Data.OleDb.OleDbConnection();
                ds3 = new DataSet();

                //The actual connection to the database//                               //XML Path to Data Base held in string...sneaky like a Ninja!//
                con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =" + textBox1.Text.ToString();

                //The SQL String you need to pass into the Data Adapter to collect the information//
                string OrdersCashCustomerSQL = "SELECT cashID, cashQTY, cashDescription, cashSupplier, cashDate, cashCost, cashSell, CashAccountRef_FKID from cashOrders INNER JOIN CashCustomers ON cashOrders.CashAccRef_FKID = cashCustomers.CashAccRef WHERE cashCustomers.CashAccRef = '" + CustomID.ToString() + "'";

                da = new System.Data.OleDb.OleDbDataAdapter(OrdersCashCustomerSQL, con);

                //The Data Adapater (da) is told to fill the DataSet (ds) with the information pulled from the SQL Query and call this fill "cashCustomers"//
                da.Fill(ds3, "OrdersCashCustomers");

                //Opens the connection//
                con.Open();

                //Closes The Connection//
                con.Dispose();

                //Tells the dataGridView to load with the information stored in table called 'cashCustomers' in the DataSet (DS)//
                dataGridView2.DataSource = ds3.Tables["OrdersCashCustomers"];



                //Change the Headers on the DataGridView2//
                dataGridView2.Columns["cashQTY"].HeaderText = "QTY";
                dataGridView2.Columns["cashDescription"].HeaderText = "DESCRIPTION";
                dataGridView2.Columns["cashSupplier"].HeaderText = "SUPPLIER";
                dataGridView2.Columns["cashDate"].HeaderText = "DATE";
                dataGridView2.Columns["cashCost"].HeaderText = "COST (£)";
                dataGridView2.Columns["cashSell"].HeaderText = "SELL (£)";

                //Hide Columns on DataGridView2//
                dataGridView2.Columns["cashID"].Visible = false;
                dataGridView2.Columns["CashAccountRef_FKID"].Visible = false;

            }

Any help with this is most grateful :)

Thanks in Advance.

Anyone got any ideas on this please?

Do I need to 'Convert' the particular Column

Hi Guys, I've been playing around with this.. and I assume I have to convert this particular data.

I know its DGV releated and when I run the Export to Excel routine from the system it shows the date correctly.

Click HereHI @ddnabe.. Thanks for your reply..

I have looked into this and I've also read that I should be able to Config Each column Accordingly.

I'm Currently using this piece of code:

        //Change the Headers on the DataGridView2//
                dataGridView2.Columns["cashQTY"].HeaderText = "QTY";
                dataGridView2.Columns["cashDescription"].HeaderText = "DESCRIPTION";
                dataGridView2.Columns["cashSupplier"].HeaderText = "SUPPLIER";
                dataGridView2.Columns["cashDate"].HeaderText = "DATE";
                dataGridView2.Columns["cashCost"].HeaderText = "COST (£)";
                dataGridView2.Columns["cashSell"].HeaderText = "SELL (£)";

                //Trying to for change of "casDate" to a type of DateTime//
                this.dataGridView2.Columns["cashDate"].ValueType = typeof(DateTime);

Currently it does not error, but it also does not Show the DateTime in the GridView when running either..

Currently stepping through it to see what happens.

Any ideas guys?

Try to set the format of the date column to something like this:

this.dataGridView2.Columns["cashDate"].DefaultCellStyle.Format = "dd/MM/yyyy";

Hi ddanbe,

Many thanks for your response!

I think I'm nearly there. However the Month is not showing up? Please see screenshots attached.

the DataSet seemsto be filled with the correct info.. Just the way the form is displaying.

Any ideas?

Ah, Found the issue.. I was using 'LowerCase' "mm" for the Month insted of "MM"..

Do you know the reason behind this?

Yes, mm stands for minutes in a format specifier.
Read this for more info.

Many thanks for your help ddanbe!

Much appricated!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.