1

I have an application page which retieve data from a stored procedure, my page give me the desired result but I discovrer in log table that this page have an error

 System.NullReferenceException: Object reference not set to an instance of an object.
   at PWC.SharePoint.Common.Layouts.PWC.RejectedReassessments.OnPreRender(EventArgs e)

when I debug I found this error in the line :

this.ReassessmentSelectorDataPager.DataBind();

this is the part of the code, I can't have further details

  protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        this.EnsureChildControls();

        try
        {

            this.ApprovedReassessmentsListView.DataBind();
            BindReassessmentSelectorToControl();
            this.ReassessmentSelectorDataPager.DataBind();
        }
        catch (Exception ex)
        {
            LoggingUtilities.LogToDatabase(PWC_LOG_TYPE.ERROR, ex.Message, ex.ToString(), this.currentWeb.Url, this.currentWeb.CurrentUser.LoginName);
        }
    }

Help please ?

1

What I understand, When you debug you get Object reference not set to an instance of an object at the data pager control this.ReassessmentSelectorDataPager.DataBind();

This issue occurs if you tried at your code to set data pager ReassessmentSelectorDataPager programmatically to null like this DataPager ReassessmentSelectorDataPager = null; so make sure that it's not set to null at any line in your code.

Also , no need to bind data pager control like this this.ReassessmentSelectorDataPager.DataBind(); it's related to a specific list view that should be defined at PagedControlID property at asp:DataPager tag, so you need to set the data source of this listview then bind it like this

 ListView1.DataSource = fucctionthat will retrive data to list view();
 ListView1.DataBind();
| improve this answer | |
  • thanks a lot for your help, actually I added in listview pagepropertieschanging and this code ' protected void ReassessmentSelectorListView_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e) { try { this.ReassessmentSelectorDataPager.SetPageProperties(e.StartRowIndex, e.MaximumRows, false); } catch (Exception ex) { LoggingUtilities.LogToDatabase(LOG_TYPE.ERROR, ex.Message, ex.ToString(), this.currentWeb.Url, this.currentWeb.CurrentUser.LoginName); } }' – BKChedlia Oct 11 '16 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.