By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,896 Members | 1,668 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,896 IT Pros & Developers. It's quick & easy.

Datagrid new row update problem.

P: n/a
BFX
Hi All,

I have datagrid with binding on dataset
this.grdMachineType.DataMember = "MachineTypes";

this.grdMachineType.DataSource = this.dsMachineTypes;

After append new row in datagrid i call this

private void tbMachineTypes_ButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

this.grdMachineType[this.grdMachineType.CurrentRowIndex,1] = false;

this.dsMachineTypes.GetChanges();

this.grdMachineType.BindingContext[this.dsMachineTypes.MachineTypes].EndCurr
entEdit();

this.daMachineT.Update(this.dsMachineTypes.Machine Types);

this.dsMachineTypes.AcceptChanges();

}

but databze haven't any changes .

If I after adding new row select another row and call save
tbMachineTypes_ButtonClick row is added.

thank's in advance for help

BFX


Jul 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
BFX
After tests i know that problem is when user dont press enter after insert
value to datagrid cell.
I try use
SendKeys.Send("{ENTER}");

but it's without any reason.

Could anyone help with this problem?

thanks
"BFX" <bf***@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi All,

I have datagrid with binding on dataset
this.grdMachineType.DataMember = "MachineTypes";

this.grdMachineType.DataSource = this.dsMachineTypes;

After append new row in datagrid i call this

private void tbMachineTypes_ButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

this.grdMachineType[this.grdMachineType.CurrentRowIndex,1] = false;

this.dsMachineTypes.GetChanges();

this.grdMachineType.BindingContext[this.dsMachineTypes.MachineTypes].EndCurr entEdit();

this.daMachineT.Update(this.dsMachineTypes.Machine Types);

this.dsMachineTypes.AcceptChanges();

}

but databze haven't any changes .

If I after adding new row select another row and call save
tbMachineTypes_ButtonClick row is added.

thank's in advance for help

BFX

Jul 21 '05 #2

P: n/a
BFX.

this.dsMachineTypes.GetChanges();

this.grdMachineType.BindingContext[this.dsMachineTypes.MachineTypes].EndCurr
entEdit();


When you do the EndCurrentEdit than the dataset can probably get changes.

Therefore I would change these two rows from position.

Don't nock to hard on your head when you read this, I don't see often
directly this kind of mistakes in my own programs.

I hope this helps,

Cor

Jul 21 '05 #3

P: n/a
BFX
Thaks for answer but I think problem is that dataset cannot get changes when
user dont't press enter after edit datagrid cell.
But I don't see why EndCurrentEdit and SendKeys.Send("{ENTER}"); don't cause
End Editing process on datagrid.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:eu*************@TK2MSFTNGP10.phx.gbl...
BFX.

this.dsMachineTypes.GetChanges();

this.grdMachineType.BindingContext[this.dsMachineTypes.MachineTypes].EndCurr entEdit();


When you do the EndCurrentEdit than the dataset can probably get changes.

Therefore I would change these two rows from position.

Don't nock to hard on your head when you read this, I don't see often
directly this kind of mistakes in my own programs.

I hope this helps,

Cor

Jul 21 '05 #4

P: n/a
BFX

I see some strange code in what you show, however see this sample.

See this sample
You have in your datagrid
1
3
5
When the users changes the 3 in a 4 and clicks the button, nothing happens
in the datagrid and in the dataset until that he changes the row or there is
done an endcurrentedit on the right datasource, what forces to push the
changes down in the datasource accoording to the bindingcontext.

There is in my opinion some strange code in what you show. I did not see it
the first time.

this.dsMachineTypes.GetChanges();
This is a result and would normally be after the endcurrentedit

If (this.dsMachineTypes.HasChanges())
DataSet dsChanges = this.dsMachineTypes.GetChanges();

(And than do the update with that dsChanges. Than the acceptchanges on the
original dataset is needed because the dataset with changes is a copy. In
the way you show it now with the original dataset is the acceptchanges
already done by the dataadapter)

I hope this helps,

Cor

"BFX" <bf***@hotmail.com> schreef in bericht
news:%2***************@TK2MSFTNGP09.phx.gbl...
Thaks for answer but I think problem is that dataset cannot get changes
when
user dont't press enter after edit datagrid cell.
But I don't see why EndCurrentEdit and SendKeys.Send("{ENTER}"); don't
cause
End Editing process on datagrid.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:eu*************@TK2MSFTNGP10.phx.gbl...
BFX.
>
> this.dsMachineTypes.GetChanges();
>
> this.grdMachineType.BindingContext[this.dsMachineTypes.MachineTypes].EndCurr > entEdit();
>


When you do the EndCurrentEdit than the dataset can probably get changes.

Therefore I would change these two rows from position.

Don't nock to hard on your head when you read this, I don't see often
directly this kind of mistakes in my own programs.

I hope this helps,

Cor


Jul 21 '05 #5

P: n/a
BFX
Thank's Cor,

but solving of my problem was easy, see folow

this.dsMachineTypes.AcceptChanges();

grdMachineType.CurrentRowIndex = -1; // it's :)

this.grdMachineType.BindingContext[this.dsMachineTypes.MachineTypes].EndCurr
entEdit();

this.daMachineT.Update(this.dsMachineTypes.Machine Types);

"Cor Ligthert" <no************@planet.nl> wrote in message
news:e6*************@tk2msftngp13.phx.gbl...
BFX

I see some strange code in what you show, however see this sample.

See this sample
You have in your datagrid
1
3
5
When the users changes the 3 in a 4 and clicks the button, nothing happens
in the datagrid and in the dataset until that he changes the row or there is done an endcurrentedit on the right datasource, what forces to push the
changes down in the datasource accoording to the bindingcontext.

There is in my opinion some strange code in what you show. I did not see it the first time.

this.dsMachineTypes.GetChanges();
This is a result and would normally be after the endcurrentedit

If (this.dsMachineTypes.HasChanges())
DataSet dsChanges = this.dsMachineTypes.GetChanges();

(And than do the update with that dsChanges. Than the acceptchanges on the
original dataset is needed because the dataset with changes is a copy. In
the way you show it now with the original dataset is the acceptchanges
already done by the dataadapter)

I hope this helps,

Cor

"BFX" <bf***@hotmail.com> schreef in bericht
news:%2***************@TK2MSFTNGP09.phx.gbl...
Thaks for answer but I think problem is that dataset cannot get changes
when
user dont't press enter after edit datagrid cell.
But I don't see why EndCurrentEdit and SendKeys.Send("{ENTER}"); don't
cause
End Editing process on datagrid.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:eu*************@TK2MSFTNGP10.phx.gbl...
BFX.

>
> this.dsMachineTypes.GetChanges();
>
>

this.grdMachineType.BindingContext[this.dsMachineTypes.MachineTypes].EndCurr
> entEdit();
>

When you do the EndCurrentEdit than the dataset can probably get changes.
Therefore I would change these two rows from position.

Don't nock to hard on your head when you read this, I don't see often
directly this kind of mistakes in my own programs.

I hope this helps,

Cor



Jul 21 '05 #6

P: n/a
> Thank's Cor,

but solving of my problem was easy, see folow
this.dsMachineTypes.AcceptChanges();
grdMachineType.CurrentRowIndex = -1; // it's :)
this.grdMachineType.BindingContext[this.dsMachineTypes.MachineTypes].EndCurr
entEdit();
this.daMachineT.Update(this.dsMachineTypes.Machine Types);

And you are sure that with this code, when somebody changing first the rows
in the grid before clicking on the button, update the changes.

It will in my opinion be a miracle however when you say so. For the rest it
is accoording what I tried to tell you all the time, where I was thinking
that you were updating using the getchanges method.

In this way will withouth that acceptchanges probably this enough.
\\\
BindingContext[dsMachineTypes.MachineTypes].EndCurrentEdit();
////

Cor
Jul 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.