This is a migrated thread and some comments may be shown as answers.

No child records to display (Error)

1 Answer 24 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gilberto Anino
Top achievements
Rank 1
Gilberto Anino asked on 07 May 2010, 10:49 PM
Hi guys... I'm building a nested grid and I always get the "No child records to display." error message when I collapse the grid...

My code is this:

protected void Page_Load(object sender, EventArgs e) 
    { 
        if (! IsPostBack) 
        { 
             string id = "dc945a82-d738-df11-b155-080027bfbfb8"
             LlenaGrid(id); 
             this.GridCompromisoHeader.DataBind(); 
        }     
    } 
 
    private void LlenaGrid(string id) 
    { 
        SqlDataAdapter ADA = new SqlDataAdapter(); 
        StringBuilder sSql = new StringBuilder(); 
 
        sSql.Append(" SELECT CAMPO1 'CAMPO1', "); 
        sSql.Append(" CAMPO2 'CAMPO2'"); 
        sSql.Append(" FROM TABLA"); 
        sSql.Append(" WHERE"); 
        sSql.Append(" LLAVE = @id"); 
 
        SqlCommand sqlcmd = new SqlCommand(sSql.ToString()); 
        SqlParameter sqlParam = new SqlParameter("@id", SqlDbType.NVarChar); 
 
        sqlParam.Value=id; 
        sqlcmd.Parameters.Add(sqlParam); 
 
        ADA.SelectCommand = sqlcmd; 
        this.GridCompromisoHeader.DataSource = ObtenerDataTable(ADA); 
              
    } 
 
    static DataTable ObtenerDataTable(SqlDataAdapter sqlAda) 
    { 
        SqlConnection sqlCnn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyCnnStr"].ConnectionString); 
        DataTable dt = new DataTable(); 
 
        try 
        { 
            sqlAda.SelectCommand.Connection = sqlCnn; 
            sqlCnn.Open(); 
            sqlAda.Fill(dt); 
            sqlCnn.Close(); 
        } 
        catch (Exception ex) 
        { 
 
            if (sqlCnn.State == ConnectionState.Open) 
            { 
                sqlCnn.Close(); 
            } 
        } 
 
        return dt;  
    } 
 
 
    protected void GridCompromisoHeader_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e) 
    { 
        GridDataItem dataItem = ((GridDataItem)(e.DetailTableView.ParentItem)); 
        SqlDataAdapter ADA = new SqlDataAdapter(); 
        StringBuilder sSql = new StringBuilder(); 
 
        sSql.Append(" SELECT CAMPO1 "); 
        sSql.Append(" FROM TABLA2"); 
        sSql.Append(" WHERE"); 
        sSql.Append(" LLAVE2 = @id"); 
        
 
        SqlCommand sqlcmd = new SqlCommand(sSql.ToString()); 
        SqlParameter sqlParam = new SqlParameter("@id", SqlDbType.NVarChar); 
 
        sqlParam.Value = dataItem["CAMPO1"].Text; 
        sqlcmd.Parameters.Add(sqlParam); 
 
        ADA.SelectCommand = sqlcmd; 
        
        try 
        { 
             
            e.DetailTableView.DataSource = ObtenerDataTable(ADA); 
             
        } 
        catch (System.Exception ex) 
        { 
             
        } 
 
    } 

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 10 May 2010, 03:15 PM
Hi Gilberto,

Can you verify that you are using the latest version 2010.1.415 of RadControls for ASP.NET AJAX in your project? If not, migrate to it following the instructions from this KB article.

Kind regards,
Pavlina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Gilberto Anino
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or