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 4561958
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:08:53+00:00 2026-05-21T18:08:53+00:00

I am getting a NullReferenceException in my codebehind for a Facebook IFRAME application. For

  • 0

I am getting a NullReferenceException in my codebehind for a Facebook IFRAME application. For the life of me I can not figure out why I am getting it.

Survey s = Survey.find(myUserID);

List<Survey> list = s.FindMatches(rdblResultsType.SelectedIndex);

if (list.Count > 0)

{
    lblResultsCount.Text = list.Count + " survey match" + (list.Count == 1 ? "" : "es");

    rdblResultsType.Items[1].Text = s.onCampus ? "On Campus" : "Off Campus";

    tblResults.Visible = true;

    foreach (Survey p in list)

        tblResults.Rows.Add(CreateRequestRow(null, p)); //Error taking place here

    TableRow footer = new TableRow();

    TableCell bottomcell = new TableCell();

    bottomcell.ColumnSpan = 2;

    bottomcell.Text = "<br/><br/>";

    footer.Cells.Add(bottomcell);

    tblResults.Rows.Add(footer);

}

And here is the method CreateRequestRow:

protected TableRow CreateRequestRow(RoommateRequest r, Survey s)
{

        long uid = (r != null ? ((r.RequesteeID == myUserID) ? r.RequesterID : r.RequesteeID) : s.facebookID.Value);
        //Facebook.Schema.user user = Api.Users.GetInfo(r != null ? ((r.RequesteeID == myUserID) ? r.RequesterID : r.RequesteeID) : s.facebookID.Value);

        TableRow tr = new TableRow();
        TableCell c1 = new TableCell();


        TableCell c2 = new TableCell();

        Button link = new Button();
        link.CssClass = "linkbutton";
        link.CommandArgument = uid.ToString();

        link.Text = s != null ? s.app.Name : (((r.RequesteeID == myUserID) ? r.RequesterName : r.RequestedName));
        if (link.Text.Trim() == "") link.Text = "Facebook User";



        link.Click += new EventHandler(btnView_Click);
        c2.Controls.Add(link);

        if (r != null)
        {
            c2.Controls.Add(new LiteralControl("<br/>"));
            c2.Controls.Add(new LiteralControl(r.DateSent.ToShortDateString()));

            if (r.Closed)
                c2.Controls.Add(new LiteralControl("<br/>Request Closed"));
            else if (r.Accepted)
                c2.Controls.Add(new LiteralControl("<br/><b>Accepted</b>"));
            else c2.Controls.Add(new LiteralControl("<br/>Awaiting Reply"));

        }

        tr.Cells.Add(c1);
        tr.Cells.Add(c2);
        return tr;




}

I have been able to step through the CreateRequestRow method without the error being thrown but it seems to take place when the returned TableRow is added to tblResults.

Any help would be greatly appreciated.

EDIT: Forgot the stack trace.

[NullReferenceException: Object reference not set to an instance of an object.]
Facebook_DisplayRequests.CreateRequestRow(RoommateRequest r, Survey s) +313
Facebook_DisplayRequests.UpdateRequests() +2389
Facebook_DisplayRequests.Page_Load(Object sender, EventArgs e) +343
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
Facebook_Graph_Toolkit.CanvasPage.OnLoad(EventArgs e) +772
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

  • 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-05-21T18:08:54+00:00Added an answer on May 21, 2026 at 6:08 pm

    I think this line:

       link.Text = s != null ? s.app.Name : (((r.RequesteeID == myUserID) ? r.RequesterName : r.RequestedName));  
    

    will throw an object ref not set because “r” is null.
    The conditional expression is based on “s” variable and you are freely using “r”.

    Edit: By the way, to debug this more effectively you should go to Debug/Exceptions and enable the breakpoints when certain exceptions occur, like this:

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting the subdomain from a URL sounds easy at first. http://www.domain.example Scan for the
Getting started with jquery and having trouble getting hello world type example going for
Without getting a degree in information retrieval, I'd like to know if there exists
Just getting my head around Ruby metaprogramming. The mixin/modules always manage to confuse me.
I getting the following error when I try to connect to my server app
Just getting started with Linq to SQL so forgive the newbie question. I'm trying
Im getting frustrated because of OpenDNS and other services (ie: roadrunner) that now always
After getting the objectEnumerator in the following code, the set1 retain count goes to
Im getting a string (simplified) from the backend that should be : { menu:
Anyone getting this error when using the new free chart controls MS bought from

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.