V
Vicky
What is the best way of converting Null value in datatable numeric column to
0.
THanks
0.
THanks
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
You can just set the datacolumn value to 0, for instance
DataTableName.Rows[0][ColumnIndex] = 0;
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemdatadatacolumnclasstopic.asp
If you mean that when you create a new row that it defaults to 0 instead of
dbnull, then you can set the DefaultValue property of the datacolumn
http://www.knowdotnet.com/articles/types.html
DataColumnName.DefaultValue = 0;
If you are talking about a dataGrid and want DbNull values to be reflected
as 0's instead of the literal null, then add a DataGridTableStyle, afterward
add a DataGridColumnStyle and set the rows DefaultValue property to 0.
http://www.knowdotnet.com/articles/kdngrid.html
Since you mention null instead of DbNull (which is what the value will come
back as) I thought this might be what you were referencing.
--
W.G. Ryan MVP Windows - Embedded
www.devbuzz.com
www.knowdotnet.com
http://www.msmvps.com/williamryan/
columnVicky said:What is the best way of converting Null value in datatable numericto
0.
THanks
Vicky said:But i am not making datatable , but opening datatable from a database using
a stored procedure.
Now in this case how to make sure that dbnull is converted to 0 withour
doing any changes in my stored procedure or database
"William Ryan eMVP"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/You can just set the datacolumn value to 0, for instance
DataTableName.Rows[0][ColumnIndex] = 0;insteadfrlrfsystemdatadatacolumnclasstopic.asp
If you mean that when you create a new row that it defaults to 0of
dbnull, then you can set the DefaultValue property of the datacolumn
http://www.knowdotnet.com/articles/types.html
DataColumnName.DefaultValue = 0;
If you are talking about a dataGrid and want DbNull values to be reflected
as 0's instead of the literal null, then add a DataGridTableStyle, afterward
add a DataGridColumnStyle and set the rows DefaultValue property to 0.
http://www.knowdotnet.com/articles/kdngrid.html
Since you mention null instead of DbNull (which is what the value will come
back as) I thought this might be what you were referencing.
--
W.G. Ryan MVP Windows - Embedded
www.devbuzz.com
www.knowdotnet.com
http://www.msmvps.com/williamryan/
column
Vicky said:But i am not making datatable , but opening datatable from a database using
a stored procedure.
Now in this case how to make sure that dbnull is converted to 0 withour
doing any changes in my stored procedure or database
"William Ryan eMVP"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/You can just set the datacolumn value to 0, for instance
DataTableName.Rows[0][ColumnIndex] = 0;insteadfrlrfsystemdatadatacolumnclasstopic.asp
If you mean that when you create a new row that it defaults to 0of
dbnull, then you can set the DefaultValue property of the datacolumn
http://www.knowdotnet.com/articles/types.html
DataColumnName.DefaultValue = 0;
If you are talking about a dataGrid and want DbNull values to be reflected
as 0's instead of the literal null, then add a DataGridTableStyle, afterward
add a DataGridColumnStyle and set the rows DefaultValue property to 0.
http://www.knowdotnet.com/articles/kdngrid.html
Since you mention null instead of DbNull (which is what the value will come
back as) I thought this might be what you were referencing.
--
W.G. Ryan MVP Windows - Embedded
www.devbuzz.com
www.knowdotnet.com
http://www.msmvps.com/williamryan/
column
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.