I have a grid with two columns Product and Purchase_Date. i get the data from db and show it in grid. if i try to add one more data to this grid on button click using the following code, i get the error "type of value has a mismatch with column ...."
DataTable dt = dataGridView1.DataSource as DataTable;
if (dt != null)
{
DataRow row = dt.NewRow();
dt.Rows.Add(textBox1.Text, dateTimePicker1.value);
dataGridView1.DataSource = dt;
}
How do i rectify it. i tried the following also datetime.parse,convert.todatetime,dateTimePicker1.value.ToString("yyyy-MM-dd hh:mm:ss").No use.