NULL problem
-
hi there, i have a problem that how can check the value of datagridview is null ?? if i write
if (DataGridView1[5, a].Value.ToString() == null)
or
if (DataGridView1[5, a].Value.ToString().Contains (null))
or
if (DataGridView1[5, a].Value.Equals(null))
all gives the same error
Object reference not set to an instance of an object.
for temporary i didstring aaa = DataGridView1[5, a].Value + "D";
if (aaa.Trim )== "D")its working but i dont like this way some know any other good and short way ??
Becoming Programmer...
-
hi there, i have a problem that how can check the value of datagridview is null ?? if i write
if (DataGridView1[5, a].Value.ToString() == null)
or
if (DataGridView1[5, a].Value.ToString().Contains (null))
or
if (DataGridView1[5, a].Value.Equals(null))
all gives the same error
Object reference not set to an instance of an object.
for temporary i didstring aaa = DataGridView1[5, a].Value + "D";
if (aaa.Trim )== "D")its working but i dont like this way some know any other good and short way ??
Becoming Programmer...
-
hi there, i have a problem that how can check the value of datagridview is null ?? if i write
if (DataGridView1[5, a].Value.ToString() == null)
or
if (DataGridView1[5, a].Value.ToString().Contains (null))
or
if (DataGridView1[5, a].Value.Equals(null))
all gives the same error
Object reference not set to an instance of an object.
for temporary i didstring aaa = DataGridView1[5, a].Value + "D";
if (aaa.Trim )== "D")its working but i dont like this way some know any other good and short way ??
Becoming Programmer...
-
hi there, i have a problem that how can check the value of datagridview is null ?? if i write
if (DataGridView1[5, a].Value.ToString() == null)
or
if (DataGridView1[5, a].Value.ToString().Contains (null))
or
if (DataGridView1[5, a].Value.Equals(null))
all gives the same error
Object reference not set to an instance of an object.
for temporary i didstring aaa = DataGridView1[5, a].Value + "D";
if (aaa.Trim )== "D")its working but i dont like this way some know any other good and short way ??
Becoming Programmer...
Hi, According to the exception it is quite clear that CLR bumped into a null value while evaluating "DataGridView1[5, a].Value" what means "DataGridView1[5, a].Value.toString()" if "DataGridView1[5, a].Value" is null ?? You might not assume DataGridView1!=null nor a!=null nor DataGridView1[5, a].Value!=null though the following test should solve your problem : if (DataGridView1[5, a]==null or DataGridView1[5, a].Value==null) { /// } Hope it helps
-
hi there, i have a problem that how can check the value of datagridview is null ?? if i write
if (DataGridView1[5, a].Value.ToString() == null)
or
if (DataGridView1[5, a].Value.ToString().Contains (null))
or
if (DataGridView1[5, a].Value.Equals(null))
all gives the same error
Object reference not set to an instance of an object.
for temporary i didstring aaa = DataGridView1[5, a].Value + "D";
if (aaa.Trim )== "D")its working but i dont like this way some know any other good and short way ??
Becoming Programmer...
if (DataGridView1[5, a] == null)
Vasudevan Deepak Kumar Personal Homepage Tech Gossips
-
if (DataGridView1[5, a] == null)
Vasudevan Deepak Kumar Personal Homepage Tech Gossips
Hello,
Vasudevan Deepak Kumar wrote:
if (DataGridView1[5, a] == null)
I guess this will not help, if this is true: for temporary i did string aaa = DataGridView1[5, a].Value + "D"; if (aaa.Trim )== "D") its working but i dont like this way
All the best, Martin
-
Hello, Have you tried: if (DataGridView1[5, a].Value != null) { //Go on }
All the best, Martin
-
hi there, i have a problem that how can check the value of datagridview is null ?? if i write
if (DataGridView1[5, a].Value.ToString() == null)
or
if (DataGridView1[5, a].Value.ToString().Contains (null))
or
if (DataGridView1[5, a].Value.Equals(null))
all gives the same error
Object reference not set to an instance of an object.
for temporary i didstring aaa = DataGridView1[5, a].Value + "D";
if (aaa.Trim )== "D")its working but i dont like this way some know any other good and short way ??
Becoming Programmer...
I think your grid must be having only 5 records from 0 to 4. So its not geting the 6th record.
Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
-
I think your grid must be having only 5 records from 0 to 4. So its not geting the 6th record.
Mujtaba "If both of us are having one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."