Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 315185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:16:06+00:00 2026-05-12T08:16:06+00:00

I have the following markup: <tr> <td valign=top align=left> <asp:Label ID=Label1 runat=server Text=Available Roles

  • 0

I have the following markup:

<tr>
    <td valign="top" align="left">
        <asp:Label ID="Label1" runat="server" Text="Available Roles" />
        <br />
        <asp:ListBox ID="availableRolesListBox" runat="server" SelectionMode="Multiple" Width="100px" Rows="10" AutoPostBack="false" />
    </td>
    <td valign="top" align="center">
        &nbsp;
        <br />
        <asp:Button ID="addToRole" runat="server" Text="--->" OnClick="addToRole_Click" />
        <br />
        <asp:Button ID="removeFromRole" runat="server" Text="<---" OnClick="removeFromRole_Click" />
    </td>
    <td valign="top" align="left">
        <asp:Label ID="Label2" runat="server" Text="User In Roles" />
        <br />
        <asp:ListBox ID="userInRolesListBox" runat="server" SelectionMode="Multiple" Width="100px" Rows="10" AutoPostBack="false" />
    </td>
</tr>

And the following in code-behind:

protected void addToRole_Click(object sender, EventArgs e)
{
    // Add user to the selected role...
    foreach (ListItem myItem in availableRolesListBox.Items)
    {
        if (myItem.Selected)
        {
            Roles.AddUserToRole(userListBox.SelectedItem.Value, myItem.Text);
        }
    }

    Refresh();
}

When I step into the code-behind absolutely no items are selected! What am I forgetting?

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:16:06+00:00Added an answer on May 12, 2026 at 8:16 am

    Are you perhaps rebinding the availableRolesListBox each time, instead of if(!IsPostback)?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following markup: <Asp:updatepanel id=up runat=server> <contenttemplate> <asp:Button id=btn runat=server text=test />
I have the following markup: <asp:DropDownList ID=dd1 AutoPostBack=true runat=server> <asp:ListItem Value=1>1</asp:ListItem> <asp:ListItem Value=2>2</asp:ListItem> </asp:DropDownList>
If I have the following markup <div id=previewNote class=note yellow style=left:25;top:25px;z-index:1;> <div class=body></div> <div
I have following markup: <div class=container> <div class=left-rect></div> <div class=text>Lorem ispum</div> <div class=right-rect></div> </div>
I have following markup which is generated dynamically using C# in my asp.net MVC2
I have the following markup. I would like to add class_A to <p class=subitem-text>
I have the following markup for my input fields: <div class=required> <label for=Name>Name <em>*</em></label>
I have the following markup; <div class=model-timeline> <p>Text</p> <div class=timeline> <div class=span-blank-5></div> <div class=time-span-1></div>
I have the following markup: <input type=text id=comboBox /> <ul id=comboBoxData> <li>1</li> <li>12</li> <li>123</li>
I have the following markup: <select style=display:none> <option value='1'>1</option> <option vlaue='2'>2</option> </select> <input type=text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.