473,666 Members | 2,357 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Databinding Issue

I am having a behaviour problem with Databinding on a C# WinForm. I
have three textboxes and a Checkbox bound to a dataset. The desired
behaviour is when I check/uncheck the checkbox, I want to either
enable, or disable and clear the corresponding textboxes.

I want the fact that I cleared the text in the textboxes to reflect in
the dataset, so I am calling the EndCurrentEdit( ) method on the
currency manager to update the dataset within the event on the
checkbox. The problem is the checkbox will not check/uncheck properly
due to the fact the currency manager is firing. If I click on the
checkbox to uncheck it in runtime, the textboxes clear, but the
checkbox remains in a checked state.

Am I doing this properly by calling EndCurrentEdit( ) on the currency
manager? How do I reflect the clearing of the textboxes in the
dataset? I should clarify, that if I clear the textboxes in code, when
the focus of the form changes to a bound control, it replaces the text
back into the cleared textboxes.
//method called when the form is loading to create the bindings
private void BindControls()
{
textbox1.DataBi ndings.Add(new Binding("Text", _myDataSet,
"MyTable.Field1 "));
textbox2.DataBi ndings.Add(new Binding("Text", _myDataSet,
"MyTable.Field2 "));
textbox3.DataBi ndings.Add(new Binding("Text", _myDataSet,
"MyTable.Field3 "));
checkbox1.DataB indings.Add(new Binding("Checke d", _myDataSet,
"MyTable.Field4 "));

//currency manager declared a member variable tothe form
_mCurrencyManag er = null;
_mCurrencyManag er = (CurrencyManage r)this.BindingC ontext[_myDataSet,
"MyTable"];
}

//event on the check box which fires when checked/unchecked
private void chkCustomAssemb ly_CheckedChang ed(object sender,
System.EventArg s e)
{
if(chkCustomAss embly.Checked == true)
{
textbox1.Enable d = true;
textbox2.Enable d = true;
textbox3.Enable d = true;
}
else
{
textbox1.Text = "";
textbox2.Text = "";
textbox3.Text = "";

textbox1.Enable d = false;
textbox2.Enable d = false;
textbox3.Enable d = false;
}

//update the binding currency manager to reflect the changes
//this call causes a problem with the behaviour of the checkbox
_mCurrencyManag er.EndCurrentEd it();
}
Jul 21 '05 #1
0 1470

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

Similar topics

0
1513
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 handler. So, inside a ColumnChanging event handler I change the value of the column that is bound to...
3
3146
by: Kevin Swanson | last post by:
I'm writing what should be a very simple app against an Oracle database. The app has a number of user controls, any one of which is loaded into a main display page using the loadControl method, depending on which menu item a user selects. Each of these controls follows the same basic pattern: Get a dataset from the database and then display the results using basic databinding. Everything works fine except that I'll occaisionally get an...
13
5333
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 Designer, the DataSource-Property appears like 'ReadOnly', there is no "dropdown" with the list from...
5
12516
by: Mark R. Dawson | last post by:
Hi all, I may be missing something with how databinding works but I have bound a datasource to a control and everything is great, the control updates to reflect the state of my datasource when I update the datasource - awesome, but I have an issue with updating from a different thread. Here is my datasource, a person class that raises the PropertyChanged event: class Person : INotifyPropertyChanged {
9
24784
by: J055 | last post by:
Hi I have a very simple configuration of the GridView with paging and sorting. When I do a postback the DataBinding event fires twice - in both the ProcessPostData and PreRender stages of the page life cycle. In this example the event fires twice when a) GridView EnableViewState=False and any image type control in the <columns/> element. When either EnableViewState is set to true or the image button is removed, the event fires once....
1
14308
by: CorporateCoder | last post by:
Hi, I am trying to bind the selected value of a databound dropdown box in a databound gridview control to the value being displayed in the template column the dropdown box has been added to. Both the grid and the dropdown box are retrieving and displaying data fine, I just cant bind the two together. I followed the instructions in the help document called 'Walkthrough: Displaying a Drop-Down List While Editing in the GridView Web...
1
16245
by: Owen Blacker | last post by:
I've spent loads of time Googling to try to work this one out and I'm sure it's something obvious. I get an InvalidOperationException reading "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control" when I start my page. Unless I'm missing something obvious, this is *not* the same issue as the "2-way databinding cascading lists" issue in...
8
2083
by: Dirk | last post by:
Hello, I have a problem to use databinding with my business layer classes. My data class does not have simple properties (string, int or datetime), instead, all my properties are objects of the generic type Field<T> (see sample code). public class Employee { public Field<stringForename
1
1623
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hello to all, I want to know if DataBinding in asp.net 2,0 is better than to fill up the values of the controls of the following form: this.miControlTextBox.Text = valorParaControlTextbox; Performance with databinding is good in asp.net 2.0 ? Would you prefer: databinding or set value to Text property of control ?
0
1072
by: nelsonbrodyk | last post by:
Hey All, I have been able to set up a databinding to a property with the following code: <TextBox x:Name="txtTextBox" Text="{Binding Path=NameFirst, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/> and in the code: profile = context.NewProfile(); profile.NameFirst = "My Name"; txtTextBox.DataContext = profile;
0
8440
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
8352
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
8780
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
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
5661
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
4192
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...
0
4358
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
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
2
2005
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.