473,786 Members | 2,583 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Collecti ons.Generic.IEn umerable<Int32d dE;

private void Form1_Load(obje ct sender, EventArgs e)
{
this.lanesTable Adapter.Fill(th is.testDataSet. lanes);
this.routeTable Adapter.Fill(th is.testDataSet. route);

ddE = (from d in this.testDataSe t.route
orderby d.dock
select d.dock).Distinc t();

foreach (Int32 d in ddE)
{
this.testDataSe t.dummy_docks.R ows.Add(new object[] { d });
}

this.routeDataG ridView.RowsAdd ed += new
DataGridViewRow sAddedEventHand ler(routeDataGr idView_RowsAdde d);

this.dataGridVi ewComboBox1.Dat aSource = this.testDataSe t.dummy_docks;
this.dataGridVi ewComboBox1.Dis playMember = "dock";

this.dataGridVi ewComboBox2.Dat aSource = this.testDataSe t.dummy_docks;
this.dataGridVi ewComboBox2.Dis playMember = "dock";

this.dataGridVi ewComboBox3.Dat aSource = this.testDataSe t.dummy_docks;
this.dataGridVi ewComboBox3.Dis playMember = "dock";

this.dataGridVi ewComboBox4.Dat aSource = this.testDataSe t.dummy_docks;
this.dataGridVi ewComboBox4.Dis playMember = "dock";

this.dataGridVi ewComboBox5.Dat aSource = this.testDataSe t.dummy_docks;
this.dataGridVi ewComboBox5.Dis playMember = "dock";
}

void routeDataGridVi ew_RowsAdded(ob ject sender,
DataGridViewRow sAddedEventArgs e)
{
this.testDataSe t.dummy_docks.C lear();
ddE = (from d in this.testDataSe t.route
orderby d.dock
select d.dock).Distinc t();

foreach (Int32 d in ddE)
{
this.testDataSe t.dummy_docks.R ows.Add(new object[] { d });
}
}

private void button1_Click(o bject sender, EventArgs e)
{
this.testDataSe t.route.Rows.Ad d(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****@microsof t.com.

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

Nov 7 '08 #1
0 1958

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

Similar topics

2
2259
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 could set a boolean value to True and then I could use that to modify what is displayed on my reports. In my dim memory is there a dirty property for forms that would do this? Would that always work for every form? Most, if not all, of my...
2
4925
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 being updated by some other process through remoting. When the page loads, I init the tree, and in my browser I can see the initialized tree. The problem is that every time that I receive update to tree from the remote process,
3
1092
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 bound via a binding source and a table adapter to a datagridview no longer recognized the changed column name and kept giving me an error on that column, evidentlty I expect that is normal. But only way I found to fix and see my changed column was...
5
11004
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 by user but not yet saved? Thanks, Bob
14
14659
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 so I get the ObjectDataSource. No problem ..... ObjectDataSource src = .... //is ok i have it
5
5182
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 all controls are populated with data from the selected row. The grid is going to be read only. Textboxes, checkboxes are going to be read/write. What event and how do I need to use to catch any change in any of the textboxes? I tried to use...
1
1574
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 , I just have a static version of rows. When other users modify the rows I do not have new changes on them. In other words I want to have most up-to-date version of rows every time. One way is to refresh dataset ( re-fetch) in short periods of...
2
1211
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 are very simple steps and I can't see where I am going wrong. Any help would be appreciated. The relevant code goes as follows; Binding controls
2
4035
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 = strFullFileName. The label would show the file name and when the form was closed and then opened it would still show the name of the last file loaded. That preserves an important piece of information. Suddenly the form has stopped doing that. When you...
0
9655
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.