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 / Windows Forms / WinForm General / February 2007

Tip: Looking for answers? Try searching our database.

DataGridView problem-

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ogmios - 16 Feb 2007 02:20 GMT
Hi to All,

I have DataGridView control bound through databindingsource to the SQLServer
2005.
The problem is when I add or edit data, situation in the database is always
step behind form situation in the grid.

I use

exampleTableAdapter.Update(exampleDataTable);

for saving and editing.. Update method is implemented good.

If I use that same line of code inside event handler of some button
everything works well but in RowLeave event it will ignore me first time and
save second time when called!!!

I would appreciate any help.

Thanx in advance.

Ognjen
RobinS - 16 Feb 2007 04:15 GMT
Are you calling the EndEdit and Validate events before calling Update on
your table adapter??

Robin S.
---------------------------------
> Hi to All,
>
[quoted text clipped - 18 lines]
>
> Ognjen
Ogmios - 17 Feb 2007 16:58 GMT
Hi Robin,

well, I call only CellValidating Event, but it is not implemented in this
moment. I don't understand why it is important?

The relevant piece of code is....

private void dataGridView1_DefaultValuesNeeded(object sender,
DataGridViewRowEventArgs e)

{

e.Row.Cells["TerminiGrupaID"].Value = listBox1.SelectedValue;

e.Row.Cells["Datum"].Value = now;

e.Row.Cells[0].Value = "12:00";

}

private void dataGridView1_CellValidating(object sender,
DataGridViewCellValidatingEventArgs e)

{

//if (dataGridView1.Columns[e.ColumnIndex].Name == "DoktorIme")

//{

// if (String.IsNullOrEmpty(e.FormattedValue.ToString()))

// {

// dataGridView1.Rows[e.RowIndex].ErrorText =

// "...";

// e.Cancel = true;

// }

//}

}

private void dataGridView1_RowLeave_1(object sender,
DataGridViewCellEventArgs e)

{

terminiAdapter.Update(terminiTable);

//dataGridView2.DataSource = terminiTable;

}

Ognjen

> Are you calling the EndEdit and Validate events before calling Update on
> your table adapter??
[quoted text clipped - 23 lines]
>>
>> Ognjen
RobinS - 19 Feb 2007 04:30 GMT
Are you using a BindingSource? You said you were, but then your code looks
like you're not. If you are, you need to call EndEdit to push the changes
down into your data source before saving the changes to the database.

Robin S.
-----------------------
> Hi Robin,
>
[quoted text clipped - 81 lines]
>>>
>>> Ognjen
Ogmios - 19 Feb 2007 11:14 GMT
I use binding source and I actually did call EndEdit before but it didn't
help?!?!
Now I use DataTable.Rows[index].EndEdit() and it helps.

I have tried all other combination including BindingSource.EndEdit(),
DataGridView.EndEdit() but this only that one works.

Thnx anyway

Ognjen
> Are you using a BindingSource? You said you were, but then your code looks
> like you're not. If you are, you need to call EndEdit to push the changes
[quoted text clipped - 87 lines]
>>>>
>>>> Ognjen
Bart Mermuys - 19 Feb 2007 16:11 GMT
Hi,

> Hi to All,
>
[quoted text clipped - 12 lines]
> everything works well but in RowLeave event it will ignore me first time
> and save second time when called!!!

RowLeave fires too soon for that, have you tried handling RowValidated
instead, can't say i tested this extensively, just an idea, i don't think
you'll need to call EndEdit then....

HTH,
Greetings

> I would appreciate any help.
>
> Thanx in advance.
>
> Ognjen

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.