Hi,
In my datagridview there are 3 columns. I am entering values in all of these but second and third column values are not compulsory.
So user can escape those two columns.
But, when inserting those values in database
If the cell 2,3 contain value then to insert that value and if it doesnot contain value (if cell is empty) then enter "----" in database.
I have used the following code, but there is no success...
int i = dataGridView1.Rows.Count;
for (int j = 0; j < i; j++)
{
string strCol2 = null;
string strCol3 = null;
if (dataGridView1.Rows[j].Cells[1].Value == null)
strCol2 = "----";
else
strCol2 = dataGridView1.Rows[j].Cells[1].Value.ToString();
if (dataGridView1.Rows[j].Cells[2].Value == null)
strCol3 = "----";
else
strCol3 = dataGridView1.Rows[j].Cells[2].Value.ToString();
}
Regards,
Vidya