title: Object Reference Not set to an instance of an object- Am getting this error
body: <pre><code>&lt;asp:TemplateField HeaderText="Team Leader"&gt;
      &lt;ItemTemplate&gt;
          &lt;asp:Label ID="gvuser_teamleader" runat="server" Text='&lt;%# Bind("TeamLeaderID")  %&gt;'&gt;&lt;/asp:Label&gt;
      &lt;/ItemTemplate&gt;
      &lt;EditItemTemplate&gt;
          &lt;asp:TextBox ID="txtuserteamleader" runat="server" Width="100px" Text='&lt;%# Eval("TeamLeaderID") %&gt;' CssClass="textboxstyle roundedcorner aligncenter gradientskyblue"&gt;&lt;/asp:TextBox&gt;
          &lt;asp:ListBox ID="listboxuserteamleader" runat="server" Width="110px" AutoPostBack="true" OnSelectedIndexChanged="listboxuserteamleader_SelectedIndexChanged" CssClass="textboxstyle roundedcorner aligncenter gradientskyblue"&gt;&lt;/asp:ListBox&gt;
          &lt;asp:DropDownExtender ID="DropDownExtender3" runat="server" TargetControlID="txtuserteamleader" DropDownControlID="listboxuserteamleader"&gt;&lt;/asp:DropDownExtender&gt;                                    
      &lt;/EditItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>When I am trying to fire the selected listbox index changed event and trying to bind the listbox selected value to textbox am getting this error. Also both controls are inside the gridview edit item template field.</p>
  
  <p>My code:</p>
  
  <pre><code>protected void listboxuserteamleader_SelectedIndexChanged(object sender, EventArgs e)
      {
          foreach (GridViewRow gvr in gvusers.Rows)
          {
              TextBox txtuserteamleader = (TextBox)gvusers.FindControl("txtuserteamleader");
              ListBox listboxuserteamleader = (ListBox)gvusers.FindControl("listboxuserteamleader");
              txtuserteamleader.Text = listboxuserteamleader.SelectedValue.ToString();
          }
      }
  </code></pre>