Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object reference not set to an instance of an object.

Status
Not open for further replies.

MayoorPatel

Programmer
Apr 10, 2006
35
GB
Hi there guys I am getting the follwing error when I run my page.

System.NullReferenceException: Object reference not set to an instance of an object.

at DCA.TribunalsService.Lands.Web.Search.Page_Load(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain()
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain()
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        PagerControl.PageSize = Configuration.GetInt("DCA.TribunalsService.Lands.Web.Search.Grid.PageSize")
        Page.RegisterClientScriptBlock("dropdowns", Me.ClientSideScript)
        Utility.PopulateCommissioners(drpCommissioner, 0)

        If Not IsPostBack Then
            Utility.PopulateCategory(drpCategory)
            PagerControl.PageIndex = 1
        End If

        If IsPostBack Then

            If Not Request.UrlReferrer.AbsolutePath.IndexOf("view.aspx") = -1 Then
                ' have come back from view page
                Utility.PopulateCategory(drpCategory)
                ' sets the page index what it was before the search
                PagerControl.PageIndex = Request.QueryString("PagerControl_PageIndex")
                '  sets the category dropdown to what it was before
                If Not Request("drpCategory").Equals(String.Empty) Then
                    drpCategory.Items.FindByValue(Request.QueryString("drpCategory")).Selected = True
                End If
            End If
            ' if the category value was not "--choose a category" then we need to populate subcategory
            ' with the corresponding value
            If Not drpCategory.SelectedItem.Value = -1 Then
                Utility.PopulateSubCategory(drpSubcategory, drpCategory.SelectedItem.Value)
                ' if the subcategory was not empty the set the selected value to that of what it was before
                If Not Request("drpSubcategory").Equals(String.Empty) Then
                    drpSubcategory.Items.FindByValue(Request("drpSubcategory").ToString).Selected = True
                End If
            End If
            ' if the commissioner dropdown was not empty then set that to what it was before
            If Not Request("drpCommissioner").Equals(String.Empty) Then
                drpCommissioner.Items.FindByValue(Request("drpCommissioner").ToString).Selected = True
            End If
        End If

        drpCategory.Attributes.Add("onchange", "populate(this, 'Form1', 'drpSubcategory', this.selectedIndex);")
        btnSearch.Attributes.Add("onclick", "document.forms[0].action = ""default.aspx""")
    End Sub

have hacked around all day to no avail, can anyone help or see the prblem?

Any help as always appreciated.

Mayoor
 
Which line do you get the error on?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Hi there. I dont actually get a page number error is just displays that message.

:-(
 
So debug the project and find out where it occurs...


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Also I forgot to mention that the problem only occurs on the live server but NOT locally. Therefore I cant debug locally.
 
Try experimenting with some Try/Catch blocks then and see where the error is occurring.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top