protected void btnRemove_Click(object sender, EventArgs e)
        {
            try
            {
                int keyValue = (int)grdSelectedRoles.GetRowValues(grdSelectedRoles.FocusedRowIndex, "SelectedID");
                SelectionItem p = new SelectionItem(keyValue, "");
                selectedList.Remove(p);
                grdSelectedRoles.DataBind();
            }
            catch
            {

            }
        }
        public void setUserRoles(User u)
        {
            UserManagementDataContext dbContext = GetDatabaseContext();

            List<UserManagement.Data.UserRole> listToRemove = new List<UserManagement.Data.UserRole>();
            List<int> listToCheck = new List<int>();

            foreach (UserManagement.Data.UserRole item in u.UserRoles)
            {
                SelectionItem sp = new SelectionItem(item.RoleID, "");
                listToCheck.Add(item.RoleID);

                if (!selectedList.Contains(sp))
                    listToRemove.Add(item);
            }

            foreach (UserManagement.Data.UserRole item in listToRemove)
            {
                dbContext.UserRoles.DeleteOnSubmit(item);
            }

            foreach (SelectionItem item in selectedList)
            {
                UserManagement.Data.UserRole ur = new UserManagement.Data.UserRole
                {
                    UserID = u.UserID,
                    RoleID = item.SelectedID
                };
                if (!listToCheck.Contains(item.SelectedID))
                {
                    u.UserRoles.Add(ur);
                }
            }
        }
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         int keyValue = (int)grdAvailableRoles.GetRowValues(grdAvailableRoles.FocusedRowIndex, "RoleID");
         string descr = (string)grdAvailableRoles.GetRowValues(grdAvailableRoles.FocusedRowIndex, "Description");
         SelectionItem p = new SelectionItem(keyValue, descr);
         if (!selectedList.Contains(p))
         {
             if ((MultipleSelection) || (selectedList.Count == 0))
                 selectedList.Add(p);
         }
         grdSelectedRoles.DataBind();
     }
     catch 
     { 
     
     }
 }