locked
working with dynamic listviews RRS feed

  • Question

  • greetings,
    Im a bit confused as to how to get the multiple values that have been selected in a listbox that is dynamically created.
    (note - i have my own webcontrol that is a listview)

    basic scenario is -
    I have a static listbox which allows multiselect, shows a list of students, so when i click on any of the student (1-2 students), it dynamically creates another listview for each of the student select which shows the subjects they have selected... place in a dynamically created cell ...inturn add it in a row.. which will then add the row into the placeholder.()all done dynamically
    now i want to add a feature where in i can change the selected subjects in the dynamic list for each of the students and allow to save in the database.

    issue -
    i dont get the basic idea as to how to access the dynamic items and get the selected values off of it.


    any help or ideas are highly apprteciated.
    regards.


    Monday, August 28, 2006 1:20 AM

All replies

  • I don't think this is the right forum for you, you should check out one of the ASP.NET Forums.

    However, if you have a reference to the dynamic ListView, you may iterate through the Controls property to get all its child controls. However, if you built the list dynamically using a Table, you should consider both the Rows then the Cells properties and you will mostly need to write some Javascipt in the client side for the effect of "selecting" rows. Are you using VS .NET 2003 or 2005?

    Monday, August 28, 2006 12:47 PM
  • I'm not sure if this is what you are looking for, but you can iterate though the listbox's items and determine the selected items value.

    foreach (ListItem Item in ListBox1.Items)
    {
    if (Item.Selected == true)
    {
    string value = Item.Value.ToString();
    }
    }

    Hope it helps.
    Monday, August 28, 2006 7:08 PM