473,396 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.

System.Collections.Generic.IEnumerable<Int32ddE;

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)
{
this.testDataSet.dummy_docks.Clear();
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,

http://www.codeproject.com/KB/vista/LINQ_1.aspx
http://www.codeproject.com/KB/vista/LINQ2.aspx
http://www.codeproject.com/KB/vista/LINQ_3.aspx

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:
ms****@microsoft.com.

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

Nov 7 '08 #1
0 1942

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Deano | last post by:
In my app I have lots of forms with data presented in various ways using all kinds of controls. Is there a simple way of detecting if the user has changed any data? I would like to do this so I...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
3
by: Bob | last post by:
I had a SQL server 2005 table in which I noticed I mispelled a column name. I changed the column name in the sql server table but after that, in the UI fortm using the table, the dataset control...
5
by: Bob | last post by:
Using Vs 2005 and Vb.NET I want to give users a message asking if they're sure they want to close the form if they had made changes to the underlying data. How do I detect if changes had been made...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
5
by: vovan | last post by:
I have set of controls (Textboxes, checkboxes etc) along with the Grid on Windows Form. I use BindingSource to populate both Grid and the set of Controls. User selects the record in the grid and...
1
by: AliRezaGoogle | last post by:
Dear Group, I have a SQL Server 2000 databse with some tables. The tables contents are modified by many users at the same time. When I fetch some rows from a table via dataset into my application...
2
by: John | last post by:
Hi I have a small app with bound controls that do not seem to be copying across the data entered into them to the underlying row for the update. This one really has me stump even though these...
2
by: KC-Mass | last post by:
I have a form that is used to ID and then load Excel files into Access. I use labels on the form to record which file was last loaded. That was accomplished with a simple lblFileLoaded =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.