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

Render telerik radgrid in html for emailing

1 Answer 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anna
Top achievements
Rank 1
Anna asked on 25 Mar 2014, 01:17 PM
I am trying to dynamically create a radgrid and render it to HTML so that I can email it to users. I
have all the data I need and the formatting of the actual grid control
finished. However, this is running in a batch process (not an aspx
page) so I am dynamically creating a dummy page, populating the grid and
trying to render it to html using the code below. However, on the call
to 'RenderControl' I get an exception: 'The control with ID 'RadGrid1'
requires a ScriptManager on the page. The ScriptManager must appear
before any controls that need it.'. Can anyone pls advise how to do
this :)

Thanks

Public Function ExecuteRadgridReport(report As IReport, ByVal params As Object(), ByVal userid As Integer) As String

Dim p As New Page
p.EnableEventValidation = False

Dim form As New HtmlForm
p.Controls.Add(form)

form.Controls.AddAt(0, New ScriptManager)

Dim x As New Telerik.Web.UI.RadGrid
x.MasterTableView.GroupsDefaultExpanded = True
x.ID = "RadGrid1"
form.Controls.Add(x)

ExecuteRadgridReport(x, report, params, userid)

'Render the grid to html
Dim sw As New StringWriter()
Dim htw As New HtmlTextWriter(sw)
x.RenderControl(htw)

'Return the html
Return sw.ToString()

End Function

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 28 Mar 2014, 09:06 AM
Hello Anna,

I am not sure what is causing the described behavior but most probably it is expected. Note that our controls are designed to work for the ASP.NET environment and forcing them to run in another one may prove impossible. Moreover the control lifecycle in such case is changed which will prevent its proper creation. That said I would suggest searching for an alternative control for displaying the data.

Regards,
Angel Petrov
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
Grid
Asked by
Anna
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or