473,547 Members | 2,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataBinding Issue with ComboBox

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 the most current version of that record).

The Problem I am having is that when the Windows Form
contains a ComboBox, when the form is initially loaded,
the First record is correctly displayed. However, as soon
as I move to another record, all of the controls are
blank, even when I move back to the original record. This
is not a case of the underlying DataTable not being
filled correctly, since while stepping through the code
in the debugger, I checked the DataTable and it contained
the correct information.

I have another form that using this same method to
display records, and it functions perfectly. The only
difference is that this form contains ComboBoxes, and the
Other form doesn't. When I remove the DataBinding
statements for the ComboBoxes, this form functions
correctly.

Ironically, I initially stored the data in XML files, and
this form functioned correctly.

Here is the Form Constructor:
public TestcaseEntry(C urrentUser p_User,
CurrentProject p_Project, string p_CaseSelection )
{
//
// Required for Windows Form
Designer support
//
InitializeCompo nent();

this.m_User = p_User;
this.m_Project = p_Project;
this.m_CaseSele ction = p_CaseSelection ;

this.m_TestType s = TestTypes.GetTy pes
();
this.m_TestType View = new DataView
(this.m_TestTyp es.TypeList);
this.m_TestType View.Sort = "Category";

this.m_Programs = Programs.GetPro gramList ();

this.m_CaseList = Testcases.GetCa seList
(p_CaseSelectio n);
this.m_RecordCo unt = this.m_CaseList .Count;
this.m_RecordIn dex = 0;

this.m_Testcase = new Testcases ();

this.m_Testcase .SetAuthorInfo (this.m_User.ID ,
this.m_User.Aut horString);

// Set the Datasource property for the Items
collection and bind this Program Control to the Testcase
Record
this.m_cboProgr am.DataSource =
this.m_Programs .Selections;
this.m_cboProgr am.DisplayMembe r = "Name";
this.m_cboProgr am.ValueMember = "ID";
this.m_cboProgr am.DataBindings .Add
("SelectedValue ",
this.m_Testcase .TestcaseList, "ProgramID" );

// Set the Datasource property for the Items
collection and bind this TestTypeCategor y Control to the
Testcase Record
this.m_cboTestT ypeCat.DataSour ce =
this.m_TestType s.CategoryList;
this.m_cboTestT ypeCat.DisplayM ember = "Name";
this.m_cboTestT ypeCat.ValueMem ber = "ID";
this.m_cboTestT ypeCat.DataBind ings.Add
("SelectedValue ",
this.m_Testcase .TestcaseList, "TestTypeCatego ry");

// Set the Datasource property for the Items
collection and bind this TestType Control to the Testcase
Record
this.m_cboTestT ype.DataSource =
this.m_TestType View;
this.m_cboTestT ype.DisplayMemb er = "Name";
this.m_cboTestT ype.ValueMember = "ID";
this.m_cboTestT ype.DataBinding s.Add
("SelectedValue ",
this.m_Testcase .TestcaseList, "TestTypeID ");

// Set the DataSource Properties for the Goto
Case List
this.cboCaseLis t.DataSource =
this.m_CaseList .Selections;
this.cboCaseLis t.DisplayMember = "ID";
this.cboCaseLis t.ValueMember = "ID";

// Bind the Textboxes to the Testcase Record
this.m_txtID.Da taBindings.Add
("Text",
this.m_Testcase .TestcaseList, "TestcaseID " );
this.m_txtAutho r.DataBindings. Add
("Text",
this.m_Testcase .TestcaseList, "AuthorStri ng" );
this.m_txtShort Description.Dat aBindings.Add
("Text",
this.m_Testcase .TestcaseList, "ShortDescripti on");
this.m_txtDescr iption.DataBind ings.Add
("Text",
this.m_Testcase .TestcaseList, "Descriptio n" );
this.m_txtExpRe s.DataBindings. Add
("Text",
this.m_Testcase .TestcaseList, "ExpectedResult " );
this.m_txtDataP rofile.DataBind ings.Add
("Text",
this.m_Testcase .TestcaseList, "DataProfil e" );

this.m_CurrentT estcase = (CurrencyManage r)
this.BindingCon text[this.m_Testcase .TestcaseList];

}

The Only solution I can think of right now is to not
perform the DataBind for the ComboBoxes, and everytime, I
get a new record, locate the appropriate entry in each of
these comboboxes, and when the value in the comboboxes is
changed by the user, to in code update the appropriate
field in the record. Is there another solution??????

Nov 15 '05 #1
0 7671

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

Similar topics

0
1510
by: Richard | last post by:
Hi, I'm having issues with DataBinding. I have a Form with two data bound comboboxes on it. When you select something in one combobox I may {or may not} want to change the selected item in the other combobox. For reasons beyond the scope of this post I need to change the second comboboxe's selected index from within a ColumnChanging event...
13
5329
by: Michael Maes | last post by:
Hi, I have a UserControl containing some controls of which one is a ComboBox. All the InternalControls are Private and some are allowed to be accessed through Public Methods. One of the things I would like to do (of course) is set the DataBindings. Something clearly is wrong with the approach I use, because I can't set the Properties in the...
1
3616
by: Gary Shell | last post by:
I have a pair of combo boxes on a form. Both have their SelectedValue property bound to a column on a table called "Input_Output". One column is called "Class" and the second is called "SubClass". Each combobox has its datasource, displaymember and SelectedValue member bound to separate tables thru individual datatsets thru individual data...
0
980
by: Kevin Hodgson | last post by:
I have a ComboBox and a TextBox bound to a Dataset/datatable returned from a SQL Database. The databinding is set in Design Mode. Everything works fine on my initial fill, and I get the correct list of items in the combobox, and the textbox which is bound to a second column in the same table, changes to the appropriate value when a new item...
3
7429
by: Dan Slaby | last post by:
I have a webservice that I want to populate a combobox on a windows form. The webservice creates the correct XML output, but when I attempt to bind it to a combobox I get this error: Additional information: Cannot bind to property or column FullName on DataSource. This error occurs with the databindings. Here is the code: --
5
3174
by: Peter M. | last post by:
I'm struggling with combobox databinding with something I consider a bug... I'm binding my combobox to an array of structs. The struct exposes two public properties, ID and Name, to be used as the value and displaymember properties. This works fine. My combobox contains the correct data. However I'm also binding my SelectedValue...
5
1814
by: Dennis | last post by:
I am trying to create a form using databinding to a dataset and one of the fields requires the user to select from a list of optons. Any hints on how to do this other than bind the field to a label or text box to display the current field value then add a combo box with the list of items to chose from? -- Dennis in Houston
7
13519
by: JTC^..^ | last post by:
When i attempt to bind to the "Text" and "Value" property of a combobox on a windows form the value is reset when I leave the combobox. The comboboxes contain the correct Text and Values. I know this as the Value property binds correctly on it own. It is only when I bind the "Text" and "Value" that the issue occurs. The following sample...
0
1301
by: theleshie | last post by:
Hi, I am creating an application which dynamically creates forms depending on the information held in a dataset (which also includes the data the application itself uses). As part of dynamically creating these forms, I need to bind controls back to their underlying tables. This has been successful with textboxes, but I am having a lot of...
0
7510
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...
0
7437
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...
1
7463
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...
0
7797
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...
0
5081
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...
0
3493
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...
1
1923
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
1050
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
748
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...

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.