Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 22nd, 2003, 04:11 AM
Registered User
 
Join Date: Aug 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default connect textbox with a dataset

Hi,
I've got a listbox linked to a DataSet in this way:
// connetto la lista di clienti ai dati
this.lbClienti.DataSource = GestoreClientiDistributori.caricaElencoClienti().T ables[0];
// imposto DENIMINAZIONEBREVE come valore visualizzato
this.lbClienti.DataTextField = "DENOMINAZIONEBREVE";
// imposto CODICE come valore nascosto
this.lbClienti.DataValueField = "CODICE";
// eseguo il binding dei dati
this.lbClienti.DataBind();
the first instrution assign the datasource as a dataset.

Now when I select a value from the listbox I would like to connect someother controls (textbox) to the other information associated with that list element.

Is it possible?
Thanks!

 
Old September 22nd, 2003, 04:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

I couldnt get u!! do u wanna make a DataBind?!?!?
Can u give me more info (by example)?!

Always:),
Hovik Melkomian.
 
Old September 22nd, 2003, 08:10 AM
Registered User
 
Join Date: Aug 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've got a drop down with a DataSource and DataTextField and DataValueField values.
DataSet ds = GestoreAnagraficheClienti.caricaElencoCantieri(thi s.ddlClienti.SelectedValue);
// imposto la sorgente di dati
this.ddlCantieri.DataSource = ds;
// la descrizione del cantiere come valore visualizzato
this.ddlCantieri.DataTextField = "cantiere_long";
// il codice come valore nascosto
this.ddlCantieri.DataValueField = "id_cantiere";

I wish to select one value from the list, and then someway to show its (i'm talking about the data in the dataTable) values in textboxes.

An example I've got a list with
cod1
cod2
cod3
but I've made an SQL with
code, name, price, ecc...
So I got them in the DataSet.
When I select cod1 from the drop down list I would fill some textbox with the other values...

I hope of to have been clearer ;)


 
Old September 22nd, 2003, 10:37 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

When you select an item in the listbox, and the postback occurs, use the listBox.SelectedIndexChanged event to do what you need. In this handler, you can run another SQL query to retrieve the data you want and write it to the text box. You could do this manually (call SQL, get value, write to textBox.Text), or with another databind.

Peter
 
Old September 22nd, 2003, 10:56 AM
Registered User
 
Join Date: Aug 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't want to do it manually because there are a lot of columns to show.
Whan you are talking about doing another databind, what do you mean in this context?
Thanks :-)

 
Old September 22nd, 2003, 11:21 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

It would seem to me that the easiest way to do what you would like is to make a SQL call to retrieve all the data you want for the specified data element in the listbox. Once you have the data (one row selected based on some key that you use as the listboxitem's "value" value) you can then set all the textboxes "Text" property to the value from the data. The manual way is really the most straightforward the way I see it.

Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Connect textbox to Access field aya_hbkenshin04 Classic ASP Databases 0 May 3rd, 2006 12:52 PM
How to databind a textbox to a dataset field aven ASP.NET 2.0 Basics 1 January 26th, 2006 11:39 PM
dataset and textbox altafingar Classic ASP Databases 1 August 13th, 2004 04:27 PM
textbox dataset altafingar ASP.NET 1.0 and 1.1 Basics 3 August 12th, 2004 02:41 PM
How to display dataset using textbox RockNRoll ASP.NET 1.0 and 1.1 Basics 1 July 4th, 2003 07:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.