Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: ListBox


Message #1 by "Alex Smotritsky" <alex.smotritsky@v...> on Thu, 20 Feb 2003 13:46:49
    while(myDataReader.Read())	//fill ListBox1
{
	strResult += myDataReader.GetString(1) + "<br>";		
	ListBox1.Items.Add(myDataReader.GetString(1));	
				
				
	}						}
Message #2 by "Alex Smotritsky" <alex.smotritsky@v...> on Thu, 20 Feb 2003 08:37:07 -0500
Sorry about the previous message.

I'm running the following code to populate a listbox:

while(myDataReader.Read()) 
{
       ListBox1.Items.Add(myDataReader.GetString(1)); 
}

This code adds items to the listbox that are visible in the listbox.
I want to also add an associated value for each item.
Does anyone know the syntax for doing that?
I don't want to use databinding here as there are actions I'd like to
take
after the addition of each item.

Message #3 by "Peter Lanoie" <planoie@n...> on Thu, 20 Feb 2003 10:11:26 -0500
Alex,

Use this:

	ListBox1.Items.Add(new ListItem(myDataReader.GetString(1),
myDataReader.GetString(1)))

Be sure you replace the second GetString index with what ever is appropriate
for your list item value.
That should do it for you.

Peter

-----Original Message-----
From: Alex Smotritsky [mailto:alex.smotritsky@v...]
Sent: Thursday, February 20, 2003 08:37
To: aspx_beginners
Subject: [aspx_beginners] ListBox


Sorry about the previous message.

I'm running the following code to populate a listbox:

while(myDataReader.Read())
{
       ListBox1.Items.Add(myDataReader.GetString(1));
}

This code adds items to the listbox that are visible in the listbox.
I want to also add an associated value for each item.
Does anyone know the syntax for doing that?
I don't want to use databinding here as there are actions I'd like to
take
after the addition of each item.



Message #4 by "Jerry Lanphear" <jerrylan@q...> on Thu, 20 Feb 2003 08:20:21 -0700
If you want two or more columns of data in your listbox you need to string
the items together as one.  The listbox does not have multiple columns.  You
will want to make sure that the font you use is one which has all characters
the same size and you pad each item on the right to make them all the same
length.

Regards
----- Original Message -----
From: "Alex Smotritsky" <alex.smotritsky@v...>
To: "aspx_beginners" <aspx_beginners@p...>
Sent: Thursday, February 20, 2003 6:37 AM
Subject: [aspx_beginners] ListBox


> Sorry about the previous message.
>
> I'm running the following code to populate a listbox:
>
> while(myDataReader.Read())
> {
>        ListBox1.Items.Add(myDataReader.GetString(1));
> }
>
> This code adds items to the listbox that are visible in the listbox.
> I want to also add an associated value for each item.
> Does anyone know the syntax for doing that?
> I don't want to use databinding here as there are actions I'd like to
> take
> after the addition of each item.
>
>
>
>

Message #5 by "Alex Smotritsky" <alex.smotritsky@v...> on Sun, 23 Feb 2003 00:26:15 -0500
I got it done, I was talking about doing this:

	while (myDataReader.Read())
	{
		ListItem myItem = new ListItem();
		myItem.Value = myDataReader.GetGuid(0).ToString();
		myItem.Text = myDataReader.GetString(1);
		ListBox1.Items.Add(myItem);
	}


-----Original Message-----
From: Jerry Lanphear [mailto:jerrylan@q...] 
Sent: Thursday, February 20, 2003 10:20 AM
To: aspx_beginners
Subject: [aspx_beginners] Re: ListBox


If you want two or more columns of data in your listbox you need to
string the items together as one.  The listbox does not have multiple
columns.  You will want to make sure that the font you use is one which
has all characters the same size and you pad each item on the right to
make them all the same length.

Regards
----- Original Message -----
From: "Alex Smotritsky" <alex.smotritsky@v...>
To: "aspx_beginners" <aspx_beginners@p...>
Sent: Thursday, February 20, 2003 6:37 AM
Subject: [aspx_beginners] ListBox


> Sorry about the previous message.
>
> I'm running the following code to populate a listbox:
>
> while(myDataReader.Read())
> {
>        ListBox1.Items.Add(myDataReader.GetString(1));
> }
>
> This code adds items to the listbox that are visible in the listbox. I

> want to also add an associated value for each item. Does anyone know 
> the syntax for doing that? I don't want to use databinding here as 
> there are actions I'd like to take
> after the addition of each item.
>
>
> ---
> Change your mail options at http://p2p.wrox.com/manager.asp or to 
> unsubscribe send a blank email to
>
>




  Return to Index