i have a problem in the following piece of code. i made a window form window form with some controls like textboxes comboBoxes and datetimepicker and buttons. i made a edit button whose functionality is that when i select a row in datagridview and press edit botton the allthe fields are filled byrecord in that row but i got an exception whiled doing this. The exception is NullReferenceException on the line which i have bold in the following piece of code. Kindly anyone can help me out from this problem why this exception is occuring and correct the code if there is mistake?
private
void Edit_Click(object sender, EventArgs e)
{
DataGridViewSelectedRowCollection rows = dataGridView1.SelectedRows;
foreach (DataGridViewRow rw in rows)
{
id =
int.Parse(rw.Cells[0].Value.ToString());
comboBox3.Text = rw.Cells[1].Value.ToString();
comboBox2.Text = rw.Cells[2].Value.ToString();
comboBox1.Text = rw.Cells[3].Value.ToString();
textBox1.Text = rw.Cells[4].Value.ToString();
richTextBox1.Text = rw.Cells[5].Value.ToString();
dateTimePicker1.Text = rw.Cells[6].Value.ToString();
}
}