Datagrids -> Default Values???

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
 
M

Morten Wennevik

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
 

Ask a Question

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.

Ask a Question

Top