-1

I am adding a user to a role in asp.net but i want to get the selected role from a dropdownlist. a single option is working for me but i need to implement a two choices dropD list.

public partial class Register : Page
{
    protected void Selection_Change(object sender, EventArgs e)
    {
        var tr = TakeRole.SelectedValue; // store it in some variable
    }
    protected void CreateUser_Click(object sender, EventArgs e)

    {
       // code 
       if (result.Succeeded)
        {
           manager.AddToRole(user.Id, "SomeRoleName");
    }
}

on aspx i have

        <asp:DropDownList id="TakeRole" AutoPostBack="True" OnSelectedIndexChanged="Selection_Change" runat="server">
          <asp:ListItem> Supplier </asp:ListItem>
          <asp:ListItem Selected="True"> Customer </asp:ListItem>
       </asp:DropDownList>
BartoszKP
  • 34,786
  • 15
  • 102
  • 130
l3ny
  • 355
  • 1
  • 7
  • 20
  • i think you are looking for this http://stackoverflow.com/questions/774587/multi-select-dropdown-list-in-asp-net – Sans Aug 23 '15 at 05:12

1 Answers1

0

Please use a listbox on multi selection mode and restrict selection to 2 items. Else you can use dropdownlist with jQuery. If you intend to use checkboxlist, then other than binding source, in check changed event count checked items to 2 and if more items are selected an alert is to be displayed.

  • the scope where the variable is, that is the problem i'm having that i need to use it inside the if statement. like i said the literal string is working but i need to call the var that has the store info. thanks – l3ny Aug 24 '15 at 23:41