Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8511447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:59:40+00:00 2026-06-11T03:59:40+00:00

I had the following code: If Page.IsPostBack = False Then ‘ If prospect is

  • 0

I had the following code:

 If Page.IsPostBack = False Then
        ' If prospect is coming from unique url
        Dim prospect_url As String = Page.RouteData.Values("value")
        ' Save prospect_url into session variable
        Session("prospect_url") = prospect_url
        Using dbContext As IRFEntities = New IRFEntities
            ' Prepopulate the states dropdown.
            Dim getStates = (From p In dbContext.IRF_States _
                             Order By p.name _
                            Select p)
            ddlState.DataSource = getStates
            ddlState.DataTextField = "name"
            ddlState.DataValueField = "id"
            ddlState.DataBind()
            ' Grab info. about prospect based on unique url.
            Dim getProspect = (From p In dbContext.IRF_Prospects _
                              Where p.url = prospect_url _
                              Select p).FirstOrDefault
            ' If they have a record...
            If getProspect IsNot Nothing Then
                'If IsDBNull(getProspect.user_id) Then
                If getProspect.user_id Is Nothing Then
                    ' Prepopulate the form with their information.
                    ' These must have a value, so we need to make sure that no column is null in the database.
                    txtFirst.Text = getProspect.first_name
                    txtLast.Text = getProspect.last_name
                    txtAddress.Text = getProspect.address
                    txtCity.Text = getProspect.city
                    ddlState.SelectedValue = getProspect.state
                    txtZip.Text = getProspect.zip
                    txtPhone.Text = getProspect.phone
                    txtEmail.Text = getProspect.email_address
                    txtYearEnrolling.Text = getProspect.enrolling_in
                Else
                    ' Redirect them to login.
                    Response.Redirect("login.aspx")
                End If
            End If
        End Using
    End If

I then added directly below ddlState.DataBind() the following:

  ' Prepopulate the programs dropdown.
             Dim getPrograms = (From p In dbContext.IRF_Program _
                              Order By p.name _
                             Select p)
            ddlProgram.DataSource = getPrograms
            ddlProgram.DataTextField = "name"
            ddlProgram.DataValueField = "id"
            ddlState.DataBind()

Now I get the error:

The ObjectContext instance has been disposed and can no longer be used for operations that require a connection

If I comment out the inserted code, the code works. Why is this code causing a problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:59:42+00:00Added an answer on June 11, 2026 at 3:59 am

    You have lost this object:

    dbContext

    That is the resources (including the connection operations) for this object have already been disposed of and cleaned up. You can re-create the object if you need to databind another drop down list.

    Dim dbContext as IRFEntities=Nothing
    
     Using dbContext= New IRFEntities
       //perform first databind
     End Using
    
     Using dbContext = New IRFEntities
      //code to perform second databind
     End Using
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I initially had the following code: Boolean successCheckPoint = false; Boolean failureCheckPoint = false;
i had used the following code in master page of asp.net project <a runat=server
I am using BeautifulSoup to scrape an URL and I had the following code,
Recently I attended a lecture concerning some design patterns: The following code had been
Somewhere here on Stack Overflow, I had found the following code some day which
I had no problem at all running the following code on a local server,
I have the following code setup: http://jsfiddle.net/bABHU/2/ Had to change it a little bit
I've been using the following code to move views around, and never had a
If I had to following file on my development branch: # file.rb class Code
I'm using the following code to hide a division on the page load: $(document).ready(function()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.