469,950 Members | 2,008 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

Re: reflect changes in data bound control when underlying data table changes

Hello Ashutosh,

I see your points. As to your two new concerns, I am give the detailed
comments in the following.

1. Is it possible to achieve this result without calling Update on the
route table? I want to give the user an option to save/reject the changes.

Yes, we can achieve the objective without calling the Update function on
the route table. The necessary thing we need to do is updating the
dummy_docks. Of course we can fill the dummy_docks from the local
routeDataGrid, so that we do not need to save changes to data base
immediately. If we are using .NET 3.0 or above version Framework, we can
adopt the LINQ to achieve that easily as follows.


private void Form1_Load(object sender, EventArgs e)
this.lanesTableAdapter.Fill(this.testDataSet.lanes );
this.routeTableAdapter.Fill(this.testDataSet.route );

ddE = (from d in this.testDataSet.route
orderby d.dock
select d.dock).Distinct();

foreach (Int32 d in ddE)
this.testDataSet.dummy_docks.Rows.Add(new object[] { d });

this.routeDataGridView.RowsAdded += new
DataGridViewRowsAddedEventHandler(routeDataGridVie w_RowsAdded);

this.dataGridViewComboBox1.DataSource = this.testDataSet.dummy_docks;
this.dataGridViewComboBox1.DisplayMember = "dock";

this.dataGridViewComboBox2.DataSource = this.testDataSet.dummy_docks;
this.dataGridViewComboBox2.DisplayMember = "dock";

this.dataGridViewComboBox3.DataSource = this.testDataSet.dummy_docks;
this.dataGridViewComboBox3.DisplayMember = "dock";

this.dataGridViewComboBox4.DataSource = this.testDataSet.dummy_docks;
this.dataGridViewComboBox4.DisplayMember = "dock";

this.dataGridViewComboBox5.DataSource = this.testDataSet.dummy_docks;
this.dataGridViewComboBox5.DisplayMember = "dock";

void routeDataGridView_RowsAdded(object sender,
DataGridViewRowsAddedEventArgs e)
ddE = (from d in this.testDataSet.route
orderby d.dock
select d.dock).Distinct();

foreach (Int32 d in ddE)
this.testDataSet.dummy_docks.Rows.Add(new object[] { d });

private void button1_Click(object sender, EventArgs e)
this.testDataSet.route.Rows.Add(new object[] {"r7", 4 });

Whenever an Row is added into the routeDataGrid, the RowAdded event fires
and we fill the dummy_docks from there. If we cannot use the LINQ, we have
to iterate through the routeDataGrid and pick up all distinct dock value by
our own codes, and then fill the dummy_docks. That means some workload.

2.I agree with your comment. If we do not want to update the local data to
the data base, we have to manipulate it on local side. The LINQ feature
will release our efforts from traversing all items for it supports querying
the memory data objects, like Array, List and DataTable. Would you like to
considering adopt the LINQ in your project? We can find some getting start
articles in the following articles,


Please let me know if you need any future assistance. I will be glad to be
of help. Have a nice day!
Best regards,
Ji Zhou
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 7 '08 #1
0 1811

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by vovan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.