I have found that I got the "Object reference not set to an instance of an object" error whenever I attempted to edit a FBA user that was in a SharePoint group that was in a sub-site that was not inheriting permissions from the parent root site. This was on the UserEdit.aspx page. This made me think that the issue was with the code attempting to check the box for the group that the user was in, however that item was not in the list of groups being retrieved, since it was only retrieving the SharePoint groups at the root site level. I then downloaded the code and in the UserEdit.aspx.cs I found that the groups are not displayed when the roles are activated (line 72). Next I went to the FBA Site Configuration screen and checked the Enable Roles checkbox. Sure enough I was then able to edit the FBA users without the error, as a work around. However to resolve the error I reviewed to code to determine why all the SharePoint groups for all the sites for the site collection were not being returned.
The root cause of this error is the binding of the groupList (the list of checkboxes for the SharePoint groups) being bound to this.Web.Groups. This "Gets the collection of cross-site groups for the site." The code to return all the SharePoint groups for all the sites groups would be SPContext.Current.Site.RootWeb.SiteGroups. This "Gets the collection of cross-site groups for the site collection." This should be changed in the following locations within the UserEdit.aspx.cs and UserNew.aspx.cs files
UserEdit.aspx.cs
line 105 change groupList.DataSource = this.Web.Groups; to groupList.DataSource = SPContext.Current.Site.RootWeb.SiteGroups;
line 219 change this.Web.Groups[groupName].AddUser(spuser); to SPContext.Current.Site.RootWeb.SiteGroups[groupName].AddUser(spuser);
line 226 change this.Web.Groups[groupName].RemoveUser(spuser); to SPContext.Current.Site.RootWeb.SiteGroups[groupName].RemoveUser(spuser);
UserNew.aspx.cs
line 52 change groupList.DataSource = this.Web.Groups; to groupList.DataSource = SPContext.Current.Site.RootWeb.SiteGroups;
line 138 change SPGroup group = this.Web.Groups[groupList.Items[i].Value]; to SPGroup group = SPContext.Current.Site.RootWeb.SiteGroups[groupList.Items[i].Value];
Hope this helps anyone else experiencing the same issue that I was having.