locked
List Box item selected status RRS feed

  • Question

  • User-425575111 posted

    I have a list box that contains some values. I want to checked just whether any of the item from tha list has been selected or not? If selected output should be true otherwise false.

    Saturday, July 2, 2011 6:27 AM

Answers

  • User-843484705 posted
    I am using this line of code in my many application. my list is multi selection.
    
    
     for (int i = 0; i < lstManaging.Items.Count; i++)
    {
    //Check if the current Item is selected in the Listbox
    if (lstManaging.Items[i].Selected)
    {
    Response.Write("True");
    }
     }
    
    
    Hope this will help you
    
    
    Happy Coding
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, July 2, 2011 6:36 AM

All replies

  • User-843484705 posted
    I am using this line of code in my many application. my list is multi selection.
    
    
     for (int i = 0; i < lstManaging.Items.Count; i++)
    {
    //Check if the current Item is selected in the Listbox
    if (lstManaging.Items[i].Selected)
    {
    Response.Write("True");
    }
     }
    
    
    Hope this will help you
    
    
    Happy Coding
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, July 2, 2011 6:36 AM
  • User-366017857 posted

    bool selected=false;

    foreach (ListItem htlRmItem in cblRoomFacilities.Items)
            {
                if (htlRmItem.Selected)
                {
                    selected=true;
                }
            }

    Saturday, July 2, 2011 6:46 AM
  • User-425575111 posted

    Thanks PrinceG. Problem not only resolved but also added my knowledge.

    Saturday, July 2, 2011 1:49 PM