hi there,

how can i validate a data grid view column to enter only the date in the data grid view column. i am doing this in a 2008 VS C# standard edition software. how can i do this.

>how can i validate a data grid view column to enter only the date in the data grid view column.

If bounded columns. See this code-snippet.

DataTable dt=new DataTable();


hey my code for retrieving data from the grid view is below:

public void AddActions()
             int countRow = dgvAList.RowCount;
             int countCol = dgvAList.ColumnCount;
             string[,] a = new string[100, 100];
             string data;
             String DataQuery = "";

             for (int k = 0; k < (countRow - 1); k++)
                 data = "'";
                 for (int j = 0; j < (countCol); j++)
                     a[j, k] = string.Format("" + dgvAList[j, k].Value);

                     if (j == 5)
                         data = data + a[j, k] + "'";
                         data = data + a[j, k] + "','";

                 DataQuery = "'" + TopicNumber + "'," + "'" + phase + "'," + data;

                 String query = @"Insert Action(TopicNo,Phase,Description,AssignedTo,DueDate,Status,DateCompleted,Comment) Values(" + DataQuery + ")";

                 SqlCommand command = new SqlCommand(query, DB.getConnection());

                 catch (Exception ex)


Hoe can i validate DueDate and CompletedDate???

Please give me an answer for this ???


Please read the rules before posting again, in particular the 'keep it organized' one - [icode]For easy readability, always wrap programming code within posts in (code blocks) and (inline code) tags. If you post a question and it gets resolved, please use the Mark Solved link to mark your thread solved. If you hit 10 infraction points your account gets an automatic ban, so it is worth obeying the rules if you want to continue to benefit from DaniWeb help.

this.dgvShortCut.CellValidating += new DataGridViewCellValidatingEventHandler(dgvShortCut_CellValidating);
private void dgvShortCut_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{   string ColName = dgvShortCut.Columns[e.ColumnIndex].Name;
    if (ColName.Equals("DOB"))
    {   if (string.IsNullOrEmpty(e.FormattedValue.ToString())) return;
        if (!Microsoft.VisualBasic.Information.IsDate(e.FormattedValue.ToString()))
        {   MessageBox.Show("Date Of Birth Date is not in correct format", "D.O.B", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            e.Cancel = true;