setting a default value for a datatable column

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do i set the default value of a datatable column to zero. At the moment it is displaying a null

Does anyone know how this is done

thank you
 
Abbas said:
How do i set the default value of a datatable column to zero. At the
moment it is displaying a null.

Does anyone know how this is done.

Well, DataColumn.DefaultValue would seem an obvious starting point, but
it really depends on what your context is.
 
Abbas said:
Where do i set this value? is it when i create the datatable or do i
write this when i create a datagridtablestyle??

I want to set a price column to a default value of 0.

You need to give more context. How are you getting the table? Is it
coming from the database, or are you creating it manually? If it's from
the database, does that not specify the default itself, if you tell the
adapter to fetch the schema?

Anyway, once you've got the table I'd imagine you can just fetch the
column and set the default at that point.
 
Back
Top