Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# WPF LINQ
private void btnUpdate_Click(object sender, RoutedEventArgs e)
                comocoLTSDataContext dc = new comocoLTSDataContext();
                DCdate dateRow = dataGrid1.SelectedValue as DCdate;
                //int m = dateRow.GKId;
                DCdate date = (from d in dc.DCdates
                               where d.GKId == dateRow.GKId & d.DId==dateRow.DId & d.DCcontainer.ContainerNo==txtContNo.Text
                               select d).Single();
                date.Date1 = dateRow.Date1;
                date.Temp00 = dateRow.Temp00;
                date.Temp06 = dateRow.Temp06;
                date.Temp12 = dateRow.Temp12;
                date.Temp18 = dateRow.Temp18;
                date.DLane = dateRow.DLane;
                date.DVentilation = dateRow.DVentilation;
                date.DRemarks = dateRow.DRemarks;
                MessageBox.Show("Row Updated Successfully");

            catch (Exception ex)
this is how I tried to update my db using datagridview. code seems to be ok. also giving the "Row updated" message. but when call LoadDates() Db has not been updated.
please help me soon...
why can't anyone give me a reason.....
Posted 12-Oct-12 15:21pm
Edited 17-Oct-12 4:37am
Wes Aday at 12-Oct-12 21:26pm
And that exception would be what?
geekbond at 28-Oct-12 6:02am
You should Refresh the DataGridView after the 'Row updated' message.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I found a good solution from this

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 693
1 George Jonsson 370
2 BillWoodruff 317
3 Sergey Alexandrovich Kryukov 259
4 Garth J Lancaster 240
0 Sergey Alexandrovich Kryukov 10,764
1 Maciej Los 5,474
2 OriginalGriff 5,472
3 CPallini 3,819
4 BillWoodruff 3,594

Advertise | Privacy | Mobile
Web03 | 2.8.141030.1 | Last Updated 3 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100