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

RadGrid.RenderControl(...) Error

1 Answer 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave Gasner
Top achievements
Rank 1
Dave Gasner asked on 17 Nov 2008, 03:40 PM
I'm in need of displaying a large amount of data at once to the screen, 1000+ records.  I know that this will take some time, but what I want is that the page will display with the "Loading..." text first, that way the other portions of the page load quickly, and then use a callBack to Render the control.

This works just fine with a GridView, but using the RadGrid it fails.  Any Help would be great.
protected void Page_Load(object sender, EventArgs e)  
{  
    if (!Page.IsPostBack)  
    {  
        ......  
        ......  
        ......  
 
        ltCallbackAttributeGrid.Text = ClientScript.GetCallbackEventReference(this,   
            "'bindAttr'""EndGetData2""'asyncgrid2'"false);  
    }  
}  
 


#region ICallbackEventHandler Members  
    private string _callBack;  
 
    public string GetCallbackResult()  
    {  
        return _callBack;  
    }  
 
    public void RaiseCallbackEvent(string eventArgument)  
    {  
        grdAttributes.DataSource = _additionalAttributeColumns;  
        grdAttributes.DataBind();  
 
        using (StringWriter sw = new StringWriter())  
        {  
            grdAttributes.RenderControl(new HtmlTextWriter(sw));  
            _callBack = sw.ToString();  
        }  
    }
#endregion 

<div id="attributeGridDiv">  
    <telerik:RadGrid runat="server" ID="grdAttributes" AutoGenerateColumns="false" 
        BorderWidth="0" Skin="Office2007" GridLines="None" > 
        <MasterTableView> 
            <Columns> 
                <telerik:GridTemplateColumn UniqueName="chkbxSelect">  
                    <ItemTemplate> 
                        <asp:CheckBox runat="server" ID="chkbxAttributeSelect" AutoPostBack="true" OnCheckedChanged="chkbxAttributeSelect_CheckedChanged" /> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridBoundColumn UniqueName="Name" DataField="string_Text" HeaderText="Name" DataType="System.String" /> 
            </Columns> 
        </MasterTableView> 
    </telerik:RadGrid> 
</div> 
<script type="text/javascript">  
    function EndGetData2(arg)   
    {  
        document.getElementById("attributeGridDiv").innerHTML = arg;  
    }  
 
    setTimeout("<asp:literal runat='server' id='ltCallbackAttributeGrid' />", 3000);  
</script> 
 

Thanks in Advance
Davey

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 20 Nov 2008, 11:34 AM
Hi Dave,

Rendering the control like this, and binding it in such a manner will break its functionalities, since using DataBind() for the control implies simple databinding. A more suitable approach in this case would be to hide the grid while it is loading, and during that time display a loading panel. When the grid has finished rendering, you can hide the panel and show the grid.
I hope this suggestion helps.

Sincerely yours,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Dave Gasner
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or