Dynamic ListBox Population n Selection
Hi,
I m trying to populate a ListBox Dynamically with MultipleSelect option and then trying to print the selected values in a different page. The cs code that i'm using for it is:
Code:
public partial class ListBox : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
AvailableReportsTableAdapter allReports = new AvailableReportsTableAdapter();
ListBox1.DataSource = allReports.GetAllReports();
ListBox1.DataTextField = "ReportName";
ListBox1.DataValueField = "ReportID";
ListBox1.DataBind();
}
protected void Btn_Click(object sender, EventArgs e)
{
Label1.Text = "Hi";
foreach (ListItem item in ListBox1.Items)
{
if (item.Selected)
{
Label1.Text += item.Text;
}
}
}
}
Unfortunately item.selected is never sets to true and the selected field doesn't get printed. I must be overlooking something n m not sure what...
Adventure, Play, Alive, Fast, Race, Addict, React, Attack, Heat, Aggression, Blast, Ahead, Escape, Challenge, Anarchy, Game, Real, Damage, Insane, Acclerate,Passion, Fear, Dominate, Crazy, Awesome, Sweat, Habit, Avenge, Balls, Imagine, Viril, Chaos, Amuse, Heavy, Panic, @#!%, Fanatic
__________________
------------------------------------------------------------------------------------------------------------
<b><i>Adventure, Play, Alive, Fast, Race, Addict, React, Attack, Heat, Aggression, Blast, Ahead, Escape, Challenge, Anarchy, Game, Real, Damage, Insane, Acclerate,Passion, Fear, Dominate, Crazy, Awesome, Sweat, Habit, Avenge, Balls, Imagine, Viril, Chaos, Amuse, Heavy, Panic, @#!%, Fanatic </i></b>
|