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

  • SEARCH
  • Home
  • 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 8998971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:06:49+00:00 2026-06-16T00:06:49+00:00

I have two User Controls. Each User Control contains a ListView. The purpose of

  • 0

I have two User Controls. Each User Control contains a ListView. The purpose of these two User Controls is to display master/detail data. When raising the event ResourceReassigned a null reference exception is always thrown. What am I doing wrong that means my event handler assignment is not working?

<asp:ListView ID="lvStaffer" runat="server">
  <LayoutTemplate>
    <table>
      <tr id="itemplaceholder" runat="server"></tr>
    </table>
  </LayoutTemplate>
  <ItemTemplate>
    <tr>
      <td>                    
        <asp:UpdatePanel ID="upResourceListViewControlItem" runat="server">
          <ContentTemplate>
            <rw:ResourceListViewControl ID="ResourceListViewControlItem" runat="server" />
          </ContentTemplate>
        </asp:UpdatePanel>
      </td>
    </tr>
  </ItemTemplate>
</asp:ListView>


public partial class Control_ResourceListViewControl : StafferWebControlBase
{

  public event EventHandler ResourceReassigned;

  protected void lvResource_ItemUpdating(Object sender, ListViewUpdateEventArgs e)
  {
    // If an item in lvResource is updated we want to refresh the master lvStaffer
    // ListView so we raise an event. Null Reference Exception is thrown here. 
    ResourceReassigned(sender, new EventArgs());
  }

}

public partial class Control_StafferListViewControl : StafferWebControlBase
{

  protected void lvStaffer_ItemDataBound(Object sender, ListViewItemEventArgs e)
  {
    Control_ResourceListViewControl resourceListViewControlItem =
(Control_ResourceListViewControl)e.Item.FindControl("ResourceListViewControlItem");

    if (resourceListViewControlItem != null)
    {
      // Each item in lvStaffer contains an instance of the ResourceListViewControl object.
      // Each object is a subscriber of the ResourceReassigned event.
      resourceListViewControlItem.ResourceReassigned += new EventHandler(lvStaffer_ResourceReassigned);
    }

  }

  protected void lvStaffer_ResourceReassigned(object sender, EventArgs e)
  {
    // Repopulates and binds the lvStaffer ListView
    ResetStafferListView();
  }

}
  • 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-16T00:06:50+00:00Added an answer on June 16, 2026 at 12:06 am

    I think you should bind your event everytime (not only if page is not post back). For example on Page_Load event or control OnLoad.

      protected void Page_Load(object sender, EventArgs e){     
      foreach (ListViewItem item in lvStaffer.Items)
            {
               Control_ResourceListViewControl resourceListViewControlItem =
            (Control_ResourceListViewControl)e.Item.FindControl("ResourceListViewControlItem");
    
            if (resourceListViewControlItem != null)
            {
               // Each item in lvStaffer contains an instance of the          ResourceListViewControl object.
              // Each object is a subscriber of the ResourceReassigned event.
               resourceListViewControlItem.ResourceReassigned += new   EventHandler(lvStaffer_ResourceReassigned);
            }
           }
    

    }

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

Sidebar

Related Questions

I have a user control in a master page with two drop down lists.
I have a user control in my wp7 application which contains two text boxes
I have two tab panels, and in each of these there is a user
I have two User Controls, and a Calendar in each. I need to be
I have Tab Control, with two tabs, and each tab contains a UserControl, the
I have two User Controls already created now I want to use one as
I have two user controls, in one of them I have a textbox, i
I have two instances of a File Browser user control, the control is just
I have a WinForms control on which I want to display two things: An
I have a situation where I am adding multiple User controls (each containintg datagridview

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.