|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
Set default values for new DataRows in Ado.Net Hi, I have a dataGridView on a WindowsForm. The DataSource for the bindingSource is a DataSet containing a table, say Orders. When the addNewItem button on the navigator is pushed, I want to provide some default values for columns in the new row in the grid: e.g. CustomerNumber and OrderNumber (incremented by one). What is the usual way of doing this? |
#2
| |||
| |||
Re: Set default values for new DataRows in Ado.Net You should try the bellow given method for every column, dataGridView1.Columns[0].CellTemplate.DefaultNewRowValue |
#3
| |||
| |||
Re: Set default values for new DataRows in Ado.Net Check the given code, Code: ' ' Create a new row, set its values and add it. ' Dim aNewRow As DataRow = myDataSet.Tables("Orders").NewRow With myDataSet.Tables("Orders") .Columns("Order_Date") = Today .Columns("Quantity") = 1 . . . .Rows.Add(aNewRow) End With
__________________ Grand Theft Auto 4 PC Video Game |
#4
| |||
| |||
Re: Set default values for new DataRows in Ado.Net This is same as above mentioned code but it is just given in the different format, you can use this also, Code: ' ' Set default values. ' With myDataSet.Tables("Orders") .Columns("Order_Date").DefaultValue = Today .Columns("Quantity").DefaultValue = 1 . . . End With ' ' Add the new row. ' Dim aNewRow As DataRow = myDataSet.Tables("Orders").NewRow myDataSet.Tables("Orders").Rows.Add(aNewRow)
__________________ Grand Theft Auto 4 PC Video Game |
![]() |
|
Tags: adonet, datarow default value, default values, vbnet |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
W32 registry values are not getting matched by the default values | Angrzej | Networking & Security | 5 | 19-05-2011 12:23 PM |
Vista - default printer doesn't stay as default | Freddie Kang | Vista Help | 8 | 19-04-2010 03:12 AM |
What are the RGB values? | Renderman21 | Operating Systems | 3 | 21-11-2009 09:45 AM |
How to use enum values in VB | $tatic | Software Development | 1 | 10-08-2009 06:25 PM |
How to set default Java parameter values | StudyBoy | Software Development | 3 | 03-03-2009 03:23 PM |