source code:
protected void Button1_Click(object sender, EventArgs e)
{
string ItemsAlreadyExists = "";
for (int i = 0; i <= ListBox1.Items.Count - 1; i++)
{
if (ListBox1.Items[i].Selected)
{
if (!ListBox2.Items.Contains(ListBox1.Items[i]))
{
ListBox2.Items.Add(ListBox1.Items[i]);
}
else
{
ItemsAlreadyExists += Convert.ToString(ListBox1.Items[i].Text) + ",";
}
}
}
if (ItemsAlreadyExists != "")
{
Response.Write(ItemsAlreadyExists.TrimEnd(',') + " Already exists in the ListBox");
}
ListBox2.ClearSelection();
}
satya
Sanoop, if this helps please login to Mark As Answer. | Alert Moderator