Render Grid

2 posts, 0 answers
  1. lampy
    lampy avatar
    47 posts
    Member since:
    Oct 2006

    Posted 03 Jun 2008 Link to this post


    Is it possible to render a usercontrol containing an ASP.Net AJAX RadGrid via to string?  I have tried and failed and wanted to see if anyone has gotten it to work.  The code that I use to render is below.

    public static string RenderView(string path, object data)  
        Page pageHolder = new Page();  
        UserControl viewControl = (UserControl)pageHolder.LoadControl(path);  
        if (data != null)  
            Type viewControlType = viewControl.GetType();  
            PropertyInfo propertyInfo = viewControlType.GetProperty("DetailsDataSource");  
            if (propertyInfo != null)  
                propertyInfo.SetValue(viewControl, data, null);  
                throw new Exception("View file: " + path + " does not have a public Data property");  
        StringWriter output = new StringWriter();  
        HttpContext.Current.Server.Execute(pageHolder, output, false);  
        return output.ToString();  
  2. Rosen
    Rosen avatar
    3247 posts

    Posted 06 Jun 2008 Link to this post

    Hi lampy,

    Unfortunately such scenario is not supported. The RadGrid control needs a real page with it's lifecycle.

    Let us know if further questions arise.

    Best wishes,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top