473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

TextBox Databinding and Triggered Event (Very Urgent!)

Hi Wizards,

I have a data set and I bound it to 2 combobox (say ComboBox1 and ComboBox2)
using ComboBox1.DataSource = MyDataSet and it worked well. That also means
that when I select an item from ComboBox1, then SelectedItem in ComboBox2
will also changed respectively, as well.

However, the problem is when I tried to bind the same dataset to a TextBox
using:

TextBox1.DataBinding.Add(new Binding("Text", MyDataSet.Tables["Table1"],
"MyDataColumn"));

It happened to be that, when selectedItem is changed in ComboBox1, the data
in TextBox1.Text does not changed. Is there any other codes/method/event
that I missed? Please note that the DataTable in combobox1 and TextBox1 is
the same. The Text in TextBox should have changed as well, right?

Please help!


Nov 15 '05 #1
6 11863
Hi Ahmad,

What is your code for combobox binding?
I think your problem is that you use different format for binding combos and
textbox thus two bindingmanagers are created and not synchronized.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Ahmad A. Rahman" <je************@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Wizards,

I have a data set and I bound it to 2 combobox (say ComboBox1 and ComboBox2) using ComboBox1.DataSource = MyDataSet and it worked well. That also means
that when I select an item from ComboBox1, then SelectedItem in ComboBox2
will also changed respectively, as well.

However, the problem is when I tried to bind the same dataset to a TextBox
using:

TextBox1.DataBinding.Add(new Binding("Text", MyDataSet.Tables["Table1"],
"MyDataColumn"));

It happened to be that, when selectedItem is changed in ComboBox1, the data in TextBox1.Text does not changed. Is there any other codes/method/event
that I missed? Please note that the DataTable in combobox1 and TextBox1 is
the same. The Text in TextBox should have changed as well, right?

Please help!

Nov 15 '05 #2
Hi,

Here's a few lines from the codes:

//-- code start --//
//I have a combobox ComboBox1 and I've already set the DisplayMember and
ValueMember at design time.
// businesslogic return a dataset with a table and that table name is
MyTable
// I set the DisplayMember = MyTable.TestKey and ValueMember =
MyTable.TestKey at design time

DataSet ds = BusinessLogic.Execute("select TestKey, TestDesc from Test",
"MyTable");

ComboBox1.DataSource = ds;

// now I want to bind the data to the TextBox.Text
TextBox1.DataBinding.Add(new Binding("Text", ds.Tables["MyTable"],
"TestDesc");
//-- code end --//

So, I supposed, when the SelectedItem in ComboBox1 is changed, I thought
data in TextBox1.Text will also change. But that didn't happened.

So, what is the problem here?

Thanx.
Nov 15 '05 #3
Hi Ahmad,

I think your problem lies in fact that once you are using ds as datasource
while for the textbox you are using the table.
Try this:

ComboBox1.DataSource = ds.Tables["MyTable"];

Here is my code that works:
//

// comboBox1

//

this.comboBox1.DataSource = this.dataTable1;

this.comboBox1.DisplayMember = "Column1";

this.comboBox1.ValueMember = "Column1";

//

// comboBox2

//

this.comboBox2.DataSource = this.dataTable1;

this.comboBox2.DisplayMember = "Column1";

this.comboBox2.ValueMember = "Column1";

//

// textBox1

//

this.textBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.dataTable1, "Column1"));
--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Ahmad A. Rahman" <je************@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

Here's a few lines from the codes:

//-- code start --//
//I have a combobox ComboBox1 and I've already set the DisplayMember and
ValueMember at design time.
// businesslogic return a dataset with a table and that table name is
MyTable
// I set the DisplayMember = MyTable.TestKey and ValueMember =
MyTable.TestKey at design time

DataSet ds = BusinessLogic.Execute("select TestKey, TestDesc from Test",
"MyTable");

ComboBox1.DataSource = ds;

// now I want to bind the data to the TextBox.Text
TextBox1.DataBinding.Add(new Binding("Text", ds.Tables["MyTable"],
"TestDesc");
//-- code end --//

So, I supposed, when the SelectedItem in ComboBox1 is changed, I thought
data in TextBox1.Text will also change. But that didn't happened.

So, what is the problem here?

Thanx.

Nov 15 '05 #4
You mean, I should use a DataTable that does not belong to any DataSet?
because refering to your codes, the only difference between my codes and
yours is that, my codes used a datatable in a dataset while yours is not.

Your codes working means that, when you change the SelectedItem in
ComboBox1, the TextBox.Text value also changed as well? Is it?

Why is it not working on mine?

"Miha Markic" <miha at rthand com> wrote in message
news:OF**************@tk2msftngp13.phx.gbl...
Hi Ahmad,

I think your problem lies in fact that once you are using ds as datasource
while for the textbox you are using the table.
Try this:

ComboBox1.DataSource = ds.Tables["MyTable"];

Here is my code that works:
//

// comboBox1

//

this.comboBox1.DataSource = this.dataTable1;

this.comboBox1.DisplayMember = "Column1";

this.comboBox1.ValueMember = "Column1";

//

// comboBox2

//

this.comboBox2.DataSource = this.dataTable1;

this.comboBox2.DisplayMember = "Column1";

this.comboBox2.ValueMember = "Column1";

//

// textBox1

//

this.textBox1.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.dataTable1, "Column1"));
--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Ahmad A. Rahman" <je************@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

Here's a few lines from the codes:

//-- code start --//
//I have a combobox ComboBox1 and I've already set the DisplayMember and
ValueMember at design time.
// businesslogic return a dataset with a table and that table name is
MyTable
// I set the DisplayMember = MyTable.TestKey and ValueMember =
MyTable.TestKey at design time

DataSet ds = BusinessLogic.Execute("select TestKey, TestDesc from Test",
"MyTable");

ComboBox1.DataSource = ds;

// now I want to bind the data to the TextBox.Text
TextBox1.DataBinding.Add(new Binding("Text", ds.Tables["MyTable"],
"TestDesc");
//-- code end --//

So, I supposed, when the SelectedItem in ComboBox1 is changed, I thought
data in TextBox1.Text will also change. But that didn't happened.

So, what is the problem here?

Thanx.


Nov 15 '05 #5

"Ahmad A. Rahman" <je************@yahoo.com> wrote in message
news:uP****************@TK2MSFTNGP11.phx.gbl...
You mean, I should use a DataTable that does not belong to any DataSet?
because refering to your codes, the only difference between my codes and
yours is that, my codes used a datatable in a dataset while yours is not.
Why do you think my is not in a dataset?
It is.
Your codes working means that, when you change the SelectedItem in
ComboBox1, the TextBox.Text value also changed as well? Is it?
Yup.
Why is it not working on mine?


Because the datasource matters - if you want to synchronize it you should
use the same.
You can't use ds for combobox and ds.Tables["MyTable"] for text box -
because the first is a dataset and the second is a datatable.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
Nov 15 '05 #6
Now it's working!!!! Obviously the datasource is the keypoint to this
problem.

Thanks a lot Miha. You really are a great help.

-cheers-
Nov 15 '05 #7

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

Similar topics

1
by: Anurag Saxena | last post by:
If someone can solve this problem,I am using ASP3.0 and IIS on windows 2000 server The complete Error is '''''''''''''''''''''''''''''''''' Server object error 'ASP 0177 : 800401f3' ...
33
by: dembla | last post by:
Hey Frnds can anyone help me in this i need a program in 'c' PROGRAM to print NxN Matrix 9 1 8 1 2 3 2 7 3 as 4 5 6 6 4 5 7 8 9 in sorted form
4
by: archana | last post by:
Hi all, I am having one confusion regarding invoking web method of web service asychronously through windows applicaiton. What i am doing is i am having one long runing web method whose one...
1
by: alok sengar | last post by:
hi, I have already tried this URL's code "http://www.java2s.com/Code/CSharp/Network/SimpleSNMP.htm" but I am getting error when i am creating a UDP type Socket and recieving packet from this...
1
by: sohail28 | last post by:
Respected Sir, I try to connect my DB which is present in my hosting server control panel using Dreamweaver MX 2004. Everything is going fine, except while testing connection configuration, its...
3
by: settyv | last post by:
Hi, I need to generate PDF stream when i click on Linkbutton in datagrid ..At present i hardcoded the DMS Id and now it is working.But i need to pass DMS ID when click linkbutton.How can i do...
1
by: rajesh.us.it.recruiter | last post by:
Hi Guys/Partners, We have a URGENT Requirement for Perl Programmer with H1 visa in India/US for one of our prestigious Client. Location : New Jersey Requirements : Should be very strong in...
6
by: jenipriya | last post by:
Hi all... its very urgent.. please........i m a beginner in oracle.... Anyone please help me wit dese codes i hv tried... and correct the errors... The table structures i hav Employee (EmpID,...
9
by: uppili4chi | last post by:
Good morning my dear friends, I am uppili from India. i am working in one mnc. I need a help very urgent. "My problem i need to write a program for search a file just like search option at...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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,...
0
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...

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.