Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2005

Tip: Looking for answers? Try searching our database.

Datagrid new row update problem.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BFX - 04 May 2005 09:43 GMT
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.MachineTypes);

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
BFX - 05 May 2005 09:08 GMT
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

> Hi All,
>
[quoted text clipped - 13 lines]
>
> this.dsMachineTypes.GetChanges();

this.grdMachineType.BindingContext[this.dsMachineTypes.MachineTypes].EndCurr
> entEdit();
>
[quoted text clipped - 12 lines]
>
> BFX
Cor Ligthert - 05 May 2005 09:28 GMT
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
BFX - 05 May 2005 11:06 GMT
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.

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

this.grdMachineType.BindingContext[this.dsMachineTypes.MachineTypes].EndCurr
> > entEdit();
>
[quoted text clipped - 8 lines]
>
> Cor
Cor Ligthert - 05 May 2005 11:49 GMT
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

> Thaks for answer but I think problem is that dataset cannot get changes
> when
[quoted text clipped - 20 lines]
>>
>> Cor
BFX - 06 May 2005 10:04 GMT
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.MachineTypes);

> BFX
>
[quoted text clipped - 38 lines]
> >>
> >> > this.dsMachineTypes.GetChanges();

this.grdMachineType.BindingContext[this.dsMachineTypes.MachineTypes].EndCurr
> >> > entEdit();
> >>
[quoted text clipped - 8 lines]
> >>
> >> Cor
Cor Ligthert - 06 May 2005 10:17 GMT
> Thank's Cor,
>
[quoted text clipped - 4 lines]
> entEdit();
> this.daMachineT.Update(this.dsMachineTypes.MachineTypes);

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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.