Hi all.
I am trying to create/update/remove aspnet users using the gridview. I have a class that inherits from the INotifyPropertyChanged however when I try to delete a record in the grid it errors and says that the collection is read-only, please could you throw some light on this;
I am trying to create/update/remove aspnet users using the gridview. I have a class that inherits from the INotifyPropertyChanged however when I try to delete a record in the grid it errors and says that the collection is read-only, please could you throw some light on this;
public sealed partial class RegistrationData : INotifyPropertyChanged
{
/// <
summary
>
/// Gets and sets the user name.
/// </
summary
>
[Key]
public string UserName { get; set; }
}
public ObservableCollection<
RegistrationData
> GetWebUsers()
{
System.Collections.ObjectModel.ObservableCollection<
RegistrationData
> Users = new System.Collections.ObjectModel.ObservableCollection<
RegistrationData
>();
var users = Membership.GetAllUsers();
foreach (MembershipUser u in users)
{
ProfileBase profile = ProfileBase.Create(u.UserName, u.IsOnline);
Users.Add(new RegistrationData
{
UserName = u.UserName,
Email = u.Email,
IsOnline = u.IsOnline,
LastActivityDate = u.LastActivityDate,
LastLockoutDate = u.LastLockoutDate,
LastLoginDate = u.LastLoginDate,
Question = u.PasswordQuestion,
FriendlyName = profile.GetPropertyValue("FriendlyName").ToString(),
PersonGuid = (System.Guid)profile.GetPropertyValue("PersonGuid"),
PasswordChange = (bool)profile.GetPropertyValue("PasswordChange"),
});
}
return Users;
//.OrderBy(e => e.UserName);
}
void MyData_LoadedData(object sender, LoadedDataEventArgs e)
{
try
{
this.MyData.LoadedData -= MyData_LoadedData;
if (e.HasError)
{
e.MarkErrorAsHandled();
MessageBox.Show("Unable to load user data please try again.", "Warning", MessageBoxButton.OK);
}
else
{
radGridView1.ItemsSource = e.AllEntities;
}
}
catch (Exception ex)
{
}
finally
{
radBusy.IsBusy = false;
}
}
if (MessageBox.Show(ApplicationStrings.DeleteRecordWarning, "Warning", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
this.radGridView1.Items.Remove(this.radGridView1.SelectedItem);
}