Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > modifying the data in Strongly typed dataset before updating to the database
 

modifying the data in Strongly typed dataset before updating to the database

Hi,

I am working on a windows form application.

I have a table(User Table)with the following 4 columns.

ID Integer,
Name varchar(50),
last_update datetime,
last_update_by varchar(10).

I have generated a dataset for this tableusing the wizard (Add new datasource).
I draged and drop this datasource on to a form with Datagridview mode option on.it has generated the Binding navigator,table adapter,binding source etc.
I have also have detail view of the datasource on the same form.
then I have removed last_update and last_update_by fields from both the views(detail and datagridview).basically i am not showing last_update and last_update_by fields to the user. But when ever user adds a new row ormodifies ID or Name, i want to update the last_update and last_update_by columns with current username and current datetime.

how to update these fields and where to update ( i mean under which event?)

i am using table adapter to update the database like this

Private

Sub USER_TABLEBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles USER_TABLEBindingNavigatorSaveItem.Click

Me.Validate()

Me.USER_TABLESBindingSource.EndEdit()

Me.TableAdapterManager.UpdateAll(Me.UserDataSet)

End Sub



please advice me, if possible with some code

Thanks
MadhavaReddy  Monday, July 27, 2009 5:25 PM
Hi MadhavaReddy,

Based on my understanding, you want to record the datetime when user edit the row, but you don't want to show these two column to the user. Am I understanding correct?

If so, please don't remove these two columns from view, but hide the columns in DataGridView only by setting the Column's Visible property to false.
dataGridView1.Columns[0].Visible = false;
The first column will be hiden.

Then you can handle the CellEndEdit event to fill these two hiden cell with current datetime.

Do you understand it?

Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Wednesday, July 29, 2009 8:11 AM
Hi MadhavaReddy,

Based on my understanding, you want to record the datetime when user edit the row, but you don't want to show these two column to the user. Am I understanding correct?

If so, please don't remove these two columns from view, but hide the columns in DataGridView only by setting the Column's Visible property to false.
dataGridView1.Columns[0].Visible = false;
The first column will be hiden.

Then you can handle the CellEndEdit event to fill these two hiden cell with current datetime.

Do you understand it?

Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Wednesday, July 29, 2009 8:11 AM

You can use google to search for other answers

Custom Search

More Threads

• Error: LookupBox.Dispose: no suitable method in LookupControlWalkthrough sample
• Event Handling
• DataGridViewlinking Scroll bar with another scrollbar
• DatagridViewLinkColumn Display
• Updating an existing row problem
• New Row Creation Problem
• Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine
• how to show data in dataGridView by using my own dataset
• Duplicate rows on dataset merge
• Bound Formatted Textbox Not Accepting New Value