Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strike>I would actually simplify things first by doing the following:</p> <pre><code> foreach (object itm in lstGroup.SelectedItems) { Group grp = new Group(); grp.GroupId = Convert.ToInt32(itm); Grps.Add(grp); } </code></pre> <p>This way the code is slightly cleaner. Testing this, I am able to get all of my selections to show up. </strike></p> <p>Since you haven't really mentioned anything about debugging, if the above solution doesn't work for you, I would put a breakpoint immediately after the <code>foreach</code> ends and look at the contents of <code>Grps</code>. If <code>Grps</code> has the right amount of items in it, then the problem is further down in your code. Perhaps it is in <code>usrGrp.UpdateUserGroups()</code> method.</p> <p>I don't really see why <code>Grps</code> wouldn't have the right number of items in it, but if it doesn't, let us know and I am sure we can figure something out.</p> <p><strong>Update</strong>: I tried a stripped down version of your code. It works properly for me. Test this out and then see if you can build it back up to do what you need it to do.</p> <p>I've defined a simple list to store the selections:</p> <pre><code>List&lt;int&gt; selectionList = new List&lt;int&gt;(); </code></pre> <p>Then, I populate it using your general framework, except I call the control directly since it already exists on the current page, rather than relying on this.FindControl(). </p> <pre><code>protected void Button1_Click(object sender, EventArgs e) { foreach (ListItem itm in UserGroup.Items) { if (itm.Selected == true) { selectionList.Add(Convert.ToInt32(itm.Value)); } } } </code></pre> <p>After this button is pressed, if I've selected 3 items, then 3 items are in selectionList. Hopefully, you have the same result. Good luck!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload