Read null value(s) from cell of DataGridView
-
Hi, kindly help me that, how to read null values from datagridview? Thanks in advance (Riaz)
-
Hi, kindly help me that, how to read null values from datagridview? Thanks in advance (Riaz)
You read it like any other value. E.g. object cellValue = dataGridView.Rows[0].Cells[0]; Doesn't matter whether it's null or not. Does this answer your question?
-
You read it like any other value. E.g. object cellValue = dataGridView.Rows[0].Cells[0]; Doesn't matter whether it's null or not. Does this answer your question?
i am facing an error "NullReferenceExeption was unhandled" using following codes. object oValueChecker = Convert.IsDBNull(dataGridView1[5, e.RowIndex].Value)? "0" : dataGridView1[5, e.RowIndex].Value.ToString().Trim(); if (oValueChecker == "0") { dataGridView1[5, e.RowIndex].Value = "0"; }
-
i am facing an error "NullReferenceExeption was unhandled" using following codes. object oValueChecker = Convert.IsDBNull(dataGridView1[5, e.RowIndex].Value)? "0" : dataGridView1[5, e.RowIndex].Value.ToString().Trim(); if (oValueChecker == "0") { dataGridView1[5, e.RowIndex].Value = "0"; }
Hi. Have you tried
if (string.IsNullOrEmpty(dataGridView1[5, e.RowIndex].Value.ToString()))
{
dataGridView1[5, e.RowIndex].Value = "0";
}I think it should work. Kjetil
-
i am facing an error "NullReferenceExeption was unhandled" using following codes. object oValueChecker = Convert.IsDBNull(dataGridView1[5, e.RowIndex].Value)? "0" : dataGridView1[5, e.RowIndex].Value.ToString().Trim(); if (oValueChecker == "0") { dataGridView1[5, e.RowIndex].Value = "0"; }
-
Hi. Have you tried
if (string.IsNullOrEmpty(dataGridView1[5, e.RowIndex].Value.ToString()))
{
dataGridView1[5, e.RowIndex].Value = "0";
}I think it should work. Kjetil
Kjetil Svendsen wrote:
string.IsNullOrEmpty(dataGridView1[5, e.RowIndex].Value.ToString())
IF the Value property is null, you will still get a
NullReferenceException
.xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008)