Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

Concatenated dropdown list (.NET, C#), save all list values?

Feb 22, 2007 4:36AM PST

I have a concatenated dropdown list getting values from several SQL Server database fields in two different tables. The dropdown populates just fine (C#, Visual Studio 2003, .NET 1.1). What I need to be able to do is save each value in the list when a user makes a selection. The relevant portion of the code populating the list is below, to make it easier for you to see what I'm doing:

if( read.Read() )
{
do
{
Location = ""; Address = ""; City = ""; State = ""; Zip = "";
if( !read.IsDBNull(1) ) Location = read.GetString(1);
else Location = "Unnamed Location";
if( !read.IsDBNull(2) ) Address = read.GetString(2);
if( !read.IsDBNull(3) ) City = read.GetString(3);
if( !read.IsDBNull(4) ) State = read.GetString(4);
if( !read.IsDBNull(5) ) Zip = read.GetString(5);
myItem = new ListItem(Location + ": " + Address + ", " + City + ", " + State + " " + Zip);
ddlAddress.Items.Add(myItem);
} while( read.Read() );
}
read.Close();

The results will read (sample) as "LOCATION X: 123 Main Street, Anytown, USA 10032"

Again, this portion of my code is working. But once the user makes a selection, I need to call a stored procedure to update a third (as yet unpopulated) database table. I need Address added to the Address field, etc. I know how to write the SQL but I do not know how to write the C# to state which portion of the list should be used for each field to be updated. There is no single ID identifying each group of fields as a single address.

Please let me know if you need more information.

Discussion is locked

- Collapse -
click(plug) and chug, so fun
Mar 2, 2007 9:46AM PST

the click even for tha list box is the event, run a switch to check tha item number that was clicked. update the info based on the item number...

- Collapse -
Found the answer
Mar 3, 2007 6:23AM PST

It's the string.split[] function.