nested grid control not accessible ? Null values ? problems <p>Asp.Net Code</p> <pre><code>&lt;asp:GridView ID="gv_current_report" runat="server" CssClass="grid" BorderStyle="Solid" BorderColor="#336699" DataKeyNames="staff_id" AutoGenerateColumns="False" GridLines="None" OnRowDataBound="gv_current_report_RowDataBound"&gt; &lt;AlternatingRowStyle BackColor="#DCE4F9" /&gt; &lt;Columns&gt; &lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;img alt="" style="cursor: pointer" src="images/plus.png" width="30" /&gt; &lt;asp:Panel ID="detail_grid" runat="server" Style="display: none"&gt; &lt;asp:GridView ID="gv_detail" runat="server" AutoGenerateColumns="false" CssClass="child-grid"&gt; &lt;Columns&gt; &lt;asp:BoundField ItemStyle-Width="150px" DataField="branch_name" HeaderText="Branch Name" /&gt; &lt;asp:BoundField ItemStyle-Width="150px" DataField="date_contacted" HeaderText="Contacted Date" /&gt; &lt;asp:BoundField ItemStyle-Width="150px" DataField="name" HeaderText="Staff Name" /&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;/asp:Panel&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; </code></pre> <p>C# Code</p> <pre><code>protected void gv_current_report_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Int32 staff_id = Convert.ToInt32(gv_current_report.DataKeys[e.Row.RowIndex].Value); db = new ReportsDataContext(); gv_detail.DataSource = db.tracker_new_report_broker_status_change_current_detail(staff_id); gv_detail.DataBind(); } } </code></pre> <p>the problem is the panel and the grid view are not accessible in c#? If I create the controls in designer, its accessible but throwing an error</p> <blockquote> <p>Object reference not set to an instance of an object</p> </blockquote> <p>Found out the grid view control is <b>NULL </b> in run time.</p> <blockquote> <p>( i.e.) gv_detail=Null</p> </blockquote> <p>Anyone please shed some light. Any help will be much appreciated!!!</p>