473,405 Members | 2,300 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,405 software developers and data experts.

Using same datasource for textbox as listbox

132 100+
Hi there.

I am looking to use a dataset return from a webservice that is currently populating a listbox, to also populate a value in a textbox that is loaded once an item is selected from the listbox.

My code for the above part that populates the listbox is as follows and this works fine.

Expand|Select|Wrap|Line Numbers
  1. listBox.DataSource = myWebService.MethodName(param1, param2);
  2. listBox.DataValueField = "RETURN_DETAILS_ONE";
  3. listBox.DataBind();
  4.  
What I am wondering is whether or not I can use this same returned dataset that is used in the listbox datasource, as the data for a textbox, which will be populated once an item is selected from the listbox?

As I am not setting a name to the dataset/datasource I am then wondering if I can then reuse this same data?

Thank you.

M :)
Jan 14 '09 #1
2 2721
E11esar
132 100+
Hi again.

I have made a small change in that I have declared a dataset and then used this to fetch the data from the webservice as follows:

Expand|Select|Wrap|Line Numbers
  1. DataSet ds1;
  2. ds1 = myWebService.MethodName(param1, param2);
  3. listBox.DataSource = ds1;
  4. listBox.DataValueField = "RETURN_DETAILS_ONE";
  5. listBox.DataBind();
  6.  
  7. lbResults.DataSource = ds1;
  8.  
In effect I want to use another value that is returned by the webservice and once an item is selected from the listbox, so use this respective value in my textbox.

Hope that makes sense..?

Thank you.

M :)
Jan 14 '09 #2
Blacky
40
First of all, you cant set a datasource property to textbox, if you want to load the same data that is selected in listbox, you can very well go for Listbox-SelectedIndexchange event and use

Txtbox1.text = listbox1.selecteditem.value.tostring();

thanks in advance
Blacky
Jan 15 '09 #3

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

Similar topics

9
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have...
0
by: JMe9ka | last post by:
I have a ListBox to which I am assigning a DataTable as a DataSource, as shown below. ======================================================= DataTable VendorData = new DataTable(); // Code...
1
by: Josema | last post by:
Hi to all, I have a class (persons) that derives from collection base: and another class (person) with this properties: -ID -Name When i have complete filled the object Persons with all...
28
by: kfrost | last post by:
I know this is probably simple but I have a C# form and the class for the form is called sbaSynch. I have a textbox name txtServerName. I'm creating a class to manipulate XML functions so I...
3
by: Alvaro E. Gonzalez V. | last post by:
Hello!!! I'm building a control that in a property assign a Dataset which they are initialized and another property Like DataMember. Similar as it happens to the DataSource property of a...
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
4
by: Stephen | last post by:
IN VB.NET I have a form with a ListBox and would like to set the DataSource property at design-time but I can't seem to declare any kind of variable that will show up in the list. I have tried a...
1
by: WhiteWizard | last post by:
First my apologies, this may be longer than the normal question. I have a windows app (.NET 2.0, VS2005), and I've written a user control that will allow the user to "drag and drop" a directory...
1
by: Refugnic | last post by:
I tried to fill a ListBox with a DataSource pointing to an ArrayList. It all works fine...up to one point. The ArrayList is dynamic, which means the contents of it change, during the course of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
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...
0
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,...
0
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...

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.