Hi i am trying to figure out why i get this error only when i try to edit a record in the database but the code has nothing to do with the edit update code. This code that is used to run a stored procedure that is used to pull groups and put the names into a list. It works if you add a record or add multiple records.
List<String> groups = new List<String>();
groups = db.spGetCurrentInsuranceGroups().ToList();
/* This where the stored procedure is being called to populate the insurance groups*/
foreach (String group in groups)
{
<option value="@group">@group</option>
}
here are images of adding a new record and editing. it populates the dropdown list. but if you click select then it wants to give a problem.
as you can see it populates the insurance part that is giving it a problem if you hit the submit to update the record.
here is the error page i get
Server Error in '/' Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 202: foreach (var group in groups.OfType().ToList())
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.] System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +271 System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) +112 System.Web.WebPages.WebPage.ExecutePageHierarchy() +128 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +131
System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +178
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.81.0