Question

I followed the tutorial http://www.codeproject.com/Articles/20047/Editable-Nested-GridView-All-in-One

In the page the table corresponding to parent Gridview is rendered a another table corresponding to child gridview has to be there within a row of parent table. But Instead it has only empty section

<tr>
    <td colspan="100%">
       <div id="div1" style=style="display:block;position:relative;left:15px;OVERFLOW:auto;WIDTH:97%">
             <div></div>
        </div>
    </td>
</tr>

While debugging from Visual Studio I came to Know that 'child gridview'(server Control) is detected that is. In ROwDataBound event of parent gridview it can find the child gridview control as follows

GridView gv = new GridView();
gv = (GridView)row.FindControl("GridView2");

I assumed this as there is no nullreference exception generated

Was it helpful?

Solution

So, have you set the datasource of the child-grid and bound it afterwards in the parent-grid's RowDataBound? Otherwise there will be no grid rendered.

var gv = (GridView)row.FindControl("GridView2");
gv.DataSource = someDataSource;
gv.DataBind();

Side-note: You don't need to create an instance of the GridView via default constructor when you have a reference anyway. The code that constructs the GridView is redundant (even on Codeproject by the way).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top