Datagrids -> Default Values???

  • Thread starter Thread starter Darryn Ross
  • Start date Start date
D

Darryn Ross

Hi,

I am adding records into my datagrid and everytime i add a new record the
default values are all (null). How do i get away from this and set some
defaults of my own. I have a custom table and column style setup and i have
tried assigning the fields to their default value... like so but nothing
changes.


DataGridTextBoxColumn CColStyle = new DataGridTextBoxColumn() ;

CColStyle.MappingName = dt.Columns.ColumnName ;

CColStyle.HeaderText = _HeadText ;

CColStyle.Width = dt.Columns.MaxLength ;

CColStyle.TextBox.Text =
BatchLstDs.Tables["tblGLBatch"].Columns.DefaultValue.ToString() ;

TSGLBatch.GridColumnStyles.Add(CColStyle);



All the columns in the database have default values set??? am i missing
something?

Regards

Darryn
 
Hi Darryn,

I'm not sure what the problem is. All the columns don't necessarily have default values, and not all of them accepts DBNull.Value either.

Depending on where you create the dataset, you might need to set DefaultValue on the datacolumns and/or set AllowDBNull = false
 
Back
Top