How to program to accept a blank values for datetime columns into the grid and below is the line of code i'm getting error:
dataGridView1.Rows[RowCount - 1].Cells[cmbIdentity.Text].Value - Now i'm getting Index value is out of range.
My total code is:
for (int RowCount = 1; RowCount <= strfile.Length - 1; RowCount++) { if (strfile[RowCount].ToString() != "") { if (RowCount != 0) { string[] column = strfile[RowCount].Split('þ'); for (int i = 1; i < column.Length - 1; i++) { if (cmbColumnCombo.SelectedIndex == ((i - 1) / 2)) { if (!string.IsNullOrEmpty(column[i]) && column[i].ToString() != "\u0014") { dataGridView1.Rows.Add(); DateTime Time = Convert.ToDateTime(column[i].ToString()); dataGridView1.Rows[RowCount - 1].Cells[txtColumnName.Text.Replace(" ", "")].Value = Time.ToString("HH:mm:ss"); dataGridView1.Rows[RowCount - 1].Cells[cmbColumnCombo.Text].Value = Time.ToString("dd/MM/yyyy"); //dataGridView1.Rows[RowCount - 1].Cells[cmbColumn1.Text].Value += column[i].ToString(); } } } for (int i = 1; i < column.Length - 1; i++) { if (cmbIdentity.SelectedIndex == ((i - 1) / 2)) { if (!string.IsNullOrEmpty(column[i]) && column[i].ToString() != "\u0014") { dataGridView1.Rows[RowCount - 1].Cells[cmbIdentity.Text].Value += column[i].ToString(); } } } } } }Can anyone please help me how to achieve this?
ali tuncerPosted Feb 16, 2016, 1:46 AM
Do you have a date time picker control in you datagridview? which one is it?
if you assign empty string to a date time picker you will get an error like "cannot convert string to System.DateTime", it sounds like you have a different error, probably index value exceeds the size of the array...Try to debug step by step, check the value of variables..
Aditya BPosted Feb 15, 2016, 6:55 AM
Shubham KumarPosted Feb 15, 2016, 6:28 AM