Re: reflect changes in data bound control when underlying data table changes
- From: Ashutosh <smbs-msdn@xxxxxxxxxxxxx>
- Date: Thu, 06 Nov 2008 16:50:03 +0530
Hi Ji,
Thanks for the solution. Actually I was also doing the same 3 things, but I was doing it at a wrong place and at wrong time. Thanks a lot.
Secondly, 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.
Lastly, I want to find out a way in which if a dock number say 5 doesn't exist anywhere in the route table, update the lane table and set the dock to 0 for which the value was 5. There are two ways to do this.
1) By writing direct SQL command. But this will require to first update the lane table, then update the dock and re-fill the lane table.
2) Traverse all the rows & columns in the lane table in the data set and update the value.
But these are not efficient enough. Is there any better way to do this?
Thanks & Regards,
Ashutosh
v-jzho@xxxxxxxxxxxxxxxxxxxx wrote:
Hello Ashutosh,.
Thanks for using Microsoft Newsgroup Support Service, my name is Ji Zhou [MSFT] and I will be working on this issue with you.
Actually the comboBox's value list will update automatically if its DataSource gets changed. In our scenario, we set the dump_docks as the DataSource. Thus, in order to make the comboBox's value list update, we firstly need to update the dump_docks table. As you described, this table's data is filled from the route table by using the select statement "select distinct dock from route order by dock". So, after we add a new row to the table route, we need to the following things,
1.Call routeTableAdapter.Update() to commit the added row to the data base.
2.Call dummy_docks.Clear() function to clear all data in the dummy table
3.Use the select command "select distinct dock from route order by dock" to fill the dummy_docks table again.
The following are codes work fine on my side, please let me know if this works on your side.
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'testDataSet.lanes' table. You can move, or remove it, as needed.
this.lanesTableAdapter.Fill(this.testDataSet.lanes);
// TODO: This line of code loads data into the 'testDataSet.route' table. You can move, or remove it, as needed.
this.routeTableAdapter.Fill(this.testDataSet.route);
this.routeTableAdapter.Adapter.SelectCommand = new System.Data.SqlClient.SqlCommand("select distinct dock from route order by dock",new System.Data.SqlClient.SqlConnection(Properties.Settings.Default.TestConnecti
onString));
this.routeTableAdapter.Adapter.Fill(this.testDataSet.dummy_docks);
this.dataGridViewComboBox1.DataSource = this.testDataSet.dummy_docks;
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";
}
private void button1_Click(object sender, EventArgs e)
{
this.testDataSet.route.Rows.Add(new object[] {"r7", 4 });
this.routeTableAdapter.Update(this.testDataSet.route);
this.testDataSet.dummy_docks.Clear();
this.routeTableAdapter.Adapter.SelectCommand = new System.Data.SqlClient.SqlCommand("select distinct dock from route order by dock", new System.Data.SqlClient.SqlConnection(Properties.Settings.Default.TestConnecti
onString));
this.routeTableAdapter.Adapter.Fill(this.testDataSet.dummy_docks);
}
Have a nice day, Ashutosh!
Best regards,
Ji Zhou (v-jzho@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
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: msdnmg@xxxxxxxxxxxxxx
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
- Follow-Ups:
- Re: reflect changes in data bound control when underlying data table changes
- From: "\"Ji Zhou [MSFT]\""
- Re: reflect changes in data bound control when underlying data table changes
- References:
- reflect changes in data bound control when underlying data table changes
- From: Ashutosh
- RE: reflect changes in data bound control when underlying data table changes
- From: "\"Ji Zhou [MSFT]\""
- reflect changes in data bound control when underlying data table changes
- Prev by Date: auto tabbing
- Next by Date: IServerChannelSink.ProcessMessage: requestMsg is null
- Previous by thread: RE: reflect changes in data bound control when underlying data table changes
- Next by thread: Re: reflect changes in data bound control when underlying data table changes
- Index(es):
Relevant Pages
|