Home All Groups Group Topic Archive Search About

cell in DataGridView BindingNavigator to format date

Author
4 May 2009 9:40 PM
JB
Hello

    Input is entered into DataGridView but if a user enters 01/01/0200
the database rejects the date. So I used the following code in the
BindingNavigatorSaveItem_Click routine:

            DataGridViewRow dateagc =
tblInvDistYearAbsDataGridView.CurrentRow;
            //Dateagc = dateagc.Cells[1].Value.ToString();
            Dateagc = Convert.ToDateTime(dateagc.Cells[1].Value.GetType());
            DateAgc = Convert.ToDateTime(Dateagc);

            //if ((Convert.ToDateTime("Date Agency") <
Convert.ToDateTime("1/1/1753")) | (Convert.ToDateTime("Date Agency") >
Convert.ToDateTime("12/31/999")))
            if ((DateAgc < Convert.ToDateTime("1/1/1753")) | (DateAgc >
Convert.ToDateTime("12/31/999")))
            {
                MessageBox.Show("Please enter a valid date");
                return;

            }

The problem is says it can't convert System.DateTime to string.

    What is the right syntax to convert the cell value to property DateTime
Format?


--
JB