Hey guys,
I've added a list of items to a listbox in my C#/ASP web form. I allow
the user to select a few items, and then click a button. I want to be able to
retrieve the items from the list box that THAT user has selected and write it
to a string.
This is what I'm doing to read the text and it's not working:
protected void Button1_Click(object sender, EventArgs e)
{
string strTemp;
foreach (ListItem lstItem in ListBox1.Items)
{
strTemp = lstItem.Text;
if (lstItem.Selected = true)
{
strTotString = strTotString + "," + strTemp;
}
}
}
Any idea what I'm doing wrong?
Not matter how many or what I highlight, it keeps giving me the very first
item in the list box (whether or not I've actually highlighted it).
Thanks!