locked
default value 0 RRS feed

  • Question

  • i have a  a select statment the bring up data from my data DB to a dataTable the i Bind the DataTable to a DataGrid

    but i can many cells with no value

    i want to make the default value to be 0

    how can i do it ?

    Monday, September 18, 2006 2:04 PM

Answers

  • It sounds like the select is returning null values and you want to replace these with the value zero in the datagrid.

    I found an easy way to do this in .NET 2.0.  What I did was create a datagrid bound to a datatable using the Wizards (drag and drop table to my form).  Then I opened the properties for the datagrid and went to the Columns collection.  For the column there is a property called DefaultCellStyle.  I clicked on this to open the CellStyle builder and there is a NullValue property in this dialog that I added 0 to and this solved the problem for me.

    Not sure how to do this in .NET 1.1, but look for help topics on DefaultCellStyle this should get you close.

    Monday, September 18, 2006 5:58 PM

All replies

  • It sounds like the select is returning null values and you want to replace these with the value zero in the datagrid.

    I found an easy way to do this in .NET 2.0.  What I did was create a datagrid bound to a datatable using the Wizards (drag and drop table to my form).  Then I opened the properties for the datagrid and went to the Columns collection.  For the column there is a property called DefaultCellStyle.  I clicked on this to open the CellStyle builder and there is a NullValue property in this dialog that I added 0 to and this solved the problem for me.

    Not sure how to do this in .NET 1.1, but look for help topics on DefaultCellStyle this should get you close.

    Monday, September 18, 2006 5:58 PM
  • Thanks.
    Monday, September 18, 2006 9:34 PM