473,624 Members | 2,135 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# App: Combobox Datatable, Associated Databindings Don't Update

4 New Member
Ok this should be simple.
I made a form, added a combobox (for selecting items to edit, not for updating fields), several textboxes, a few checkboxes etc. On formshow it connects to my database, draws down the existing data, no problem. All the records in the datatable that were the result of a query, I could select from, and the other databound components would display the records contents, no problem..... however.... when i add a new row, the combobox updates, but if i select the NEW item in it, all the databound objects are still pointing to the record to which I had selected prior, and if i make changes to their contents, it updates the fields associated with the priorily selected record, I can still select the original records and edit their contents just fine... but the NEW record's contents never display, and the record to which the databound objects are pointing, never change either... can someone please help before all my hair turns white ? LOL

the setup code that establishes databindings and populates the data table is as follows.
Expand|Select|Wrap|Line Numbers
  1.     mySqlDataAdapter1.SelectCommand =
  2.     new MySql.Data.MySqlClient.MySqlCommand(
  3. "SELECT *,CONCAT(ENTRY_NO,\":\", TYPENAME) AS DISPLAYVAL FROM FILEINFO.FILETYPE ORDER BY TYPENAME",
  4. mySqlConnection1);
  5.  
  6.     mySqlDataAdapter1.Fill(dataSet1);
  7.  
  8.     ComboList = new DataTable();
  9.  
  10.     ComboList = dataSet1.Tables[0];
  11.  
  12.     comboBox1.DataSource = ComboList;
  13.     comboBox1.DisplayMember = "DISPLAYVAL";
  14.     comboBox1.ValueMember = "ENTRY_NO";
  15.  
  16.  
  17.     FILENAME.DataBindings.Clear();
  18.     FILENAME.DataBindings.Add("TEXT", ComboList, "TYPENAME");
  19.  
  20.     DESCRIPTION.DataBindings.Clear();
  21.     DESCRIPTION.DataBindings.Add("TEXT", ComboList, "DESCRIPTION");
  22.  
  23.     FILEEXT.DataBindings.Clear();
  24.     FILEEXT.DataBindings.Add("TEXT", ComboList, "EXTENSION");
  25.  
  26.     RECLENGTH.DataBindings.Clear();
  27.     RECLENGTH.DataBindings.Add("TEXT", ComboList, "RECORDLENGTH");
  28.     RECLENGTH.CausesValidation = true;
  29.  
  30.     ISRECDELIM.DataBindings.Clear();
  31.     ISRECDELIM.DataBindings.Add("CHECKED", ComboList, "IS_RECORD_DELIM");
  32.  
  33.     ISFIELDDELIM.DataBindings.Clear();
  34.     ISFIELDDELIM.DataBindings.Add("CHECKED", ComboList, "IS_FIELD_DELIM");
  35.  
  36.     ISFLATFILE.DataBindings.Clear();
  37.     ISFLATFILE.DataBindings.Add("CHECKED", ComboList, "IS_FLAT");
  38.  
  39.     RECDELIM.DataBindings.Clear();
  40.     RECDELIM.DataBindings.Add("TEXT", ComboList, "RECORD_DELIM");
  41.  
  42.     FIELDDELIM.DataBindings.Clear();
  43.     FIELDDELIM.DataBindings.Add("TEXT", ComboList, "FIELD_DELIM");
  44.  
I have a button which is labeled new record, its click event handlers is as follows:
Expand|Select|Wrap|Line Numbers
  1. private void button3_Click(object sender, EventArgs e)
  2. {
  3.  
  4.     DataRow r = ComboList.NewRow();
  5.  
  6.     r["ENTRY_NO"] = DBNull.Value;
  7.     r["TYPENAME"] = "NEW FILE TYPE";
  8.     r["DISPLAYVAL"] = "X: " + r["TYPENAME"].ToString();
  9.     ComboList.Rows.Add(r);
  10. }
  11.  
Code mapped to the datatables.onco lumnchanged event is as follows....
Expand|Select|Wrap|Line Numbers
  1. private void UpdateDisplayVal ( Object sender,
  2. DataColumnChangeEventArgs e)
  3. {
  4.     if (e.Column.ColumnName == "TYPENAME")
  5.     {
  6.         e.Row["DISPLAYVAL"] = e.Row["ENTRY_NO"].ToString() + ": " + e.Row["TYPENAME"].ToString();
  7.     }
  8. }
The combobox updates with a value "X: NEW FILE TYPE", when i select a new item in it
none of the other bound objects update with the new value, as they do when i selected
the old item.
Nov 30 '07 #1
0 2296

Sign in to post your reply or Sign up for a free account.

Similar topics

0
7678
by: Timothy White | last post by:
I have a Windows Form Which Displays one record at a time. The DataTable object which is bound to the Form Controls only contains the record that is being displayed. When I need to display a different record, any changes in the current record are saved to an Access Database, the DataTable's Row Collection is Cleared and the New Record is read into the DataTable. (This is done to ensure that when the User goes to view a record, they get...
4
1730
by: al | last post by:
Greetings, As I understands it, SelectedValud of combobox reads its value from ValueMember property of the combobox. This doesn't work with me. What happens is just randome update. This is the code, 'Here I set connectin and commands Dim cn As SqlConnection = New SqlConnection(str)
20
2020
by: MadCrazyNewbie | last post by:
Hey group, I keep getting the following error: "An unhandled exception of type 'System.IndexOutOfRangeException' occurred in system.data.dll Additional information: There is no row at position 1." on the following line of code:
4
3792
by: Tom | last post by:
I have a dataset called "employees" with a field called "gender". How do I bind a combobox to it so that the user is only allowed to select "M" or "F" and that value ends up in the dataset? Note that M and F are not in a table of a database. I have entered them directly into the Items collection of the combobox via the property editor. Thanks
11
2529
by: roy_ware | last post by:
I have a sweet application developed in MS Access 2000, but need to re-develop it in VB.NET to completely hide Access and make it a wee bit more user-friendly. I've developed MS Access/VB 5 applications in the past, but this VB.NET is a whole new beast. How does one gain simple access to the database - other than that butt-ugly Data Grid? I've been using Wrox's Beginning VB.NET, but could sure use some suggestions on better reference...
30
4564
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a corresponding field in the lookup table. In my data table we store the ID in what I will call the 'key' field. == Description of the desired operation:
4
4608
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box bound to a table as a lookup, drawing values from another table to populate the available selections. This all worked fine in VB6. I have distilled the problem down to a simple form drawing data from the Northwind database for a representative...
6
2871
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox and the coresponding 'Id' from the lookup table is to be inserted into the field of the new record. I have two simple tables. "tblPerson" is the data table. The lookup
9
4012
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New DataTable("SliceInfo") Dim tblSliceRatings As New DataTable("SliceRatings") '.... All the adding datacolumns, datarows, etc. goes here.. DatasetInit.Tables.Add(tblSliceInfo)
0
8677
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8474
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
7158
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
6110
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
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2605
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
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
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.