Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
645
Can a Ultragrid ignore a primary-key-column with a null-value until I choose to save?
posted

Hi,

I have a ultragrid with data binding to a datatable from a dataset. 
The bound table has the following columns:

RecYear primaryKey - also foreign key in linked table
RecID primaryKey - also foreign key in linked table
SampleID PrimaryKey
SampleType
SampleCount

I want to only show two columns in the grid: SampleType and SampleCount
Inserting new data into the table is taken care of by a stored procedure which takes five parameters: @SampleType and @SampleCount.
Pluss: @RecYear', '@RecID' and  '@SampleID output'.
The @RecYear', '@RecID' I will set in my Save method of the form. 
The sampleID is calculated in the stored procedure, and it is only an output parameter.

The problem is that the ultragrid and/or the bound datatable cannot wait with the assigning of the primary keys until I want to 'batch save' one or more added rows. The grid throws warning after leaving the the first new row in the grid.

Is is possible for make the grid ignore null-data for primary keys until updating the table on the SQL server?

I use dataset, tableadapter and bindingsource

bw
Kai

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi Kai,

    This doesn't really have anything to do with the grid - it's the DataTable that will not allow you to commit a row without a required field.

    There are probably a lot of resources on this type of problem available from Microsoft or some of their forums. I remember reading something many years ago about a technique where you change the DataTable field to product an auto-generated primary key value using negative numbers so that the row can be added temporarily, and then later on you fill in the correct key value when you commit the changes to the database and it generates a real key.

Children