Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

dim Dr as datarow

Dim Dt As DataTable = dg1.datasoursse

Dim Hit As DataGrid.HitTestInfo

Hit = DG1.HitTest(e.X, e.Y)

Dr = Dt.Rows(Hit.Row)

Dr.BeginEdit()

Dr("fieldname") = "xyx"

Dim Ds_temp As DataSet = Ds1.GetChanges(DataRowState.Modified) ' Ds1 is the main Dataset attached to the Datagrid DG1

Adp1.Update(Ds_temp)

Dr.AcceptChanges()

 

 

 

In the above code , I am modifing a field but , the dataset says that neither of the field is changed or modified , hence I get the problem in the next line when updating DATAADAPTER Adp1.

 

Where am I wrong

  • *Experts*
Posted

Your working to hard.

Since the datagrid is bound to the ds1 (I assume it is your datasource...if not, we have other issues), any edit of the datagrid will be persisted to the dataset. The rowstate will be set to modified and all you have to do is run an .update on the adapter. You may have to include a

 Me.BindingContext(DataSet, "TableName").EndCurrentEdit()

or, in c#,

this.BindingContext[DataSet,"TableName"].EndCurrentEdit()

 

before your DataAdapter.update call.

 

 

Jon

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...