it has been years since i have not dealt with reporting.. so, i am a total newbie for this..
in this post, i share my one-day activity on warming up using telerik reports, a sample telerik report about a specific user's information viewed in a web app and how to deploy it in a remote server..
first thinngs first.. my bookmarks:
Report library part:
Now, the first step is creating a report library project.. Then a telerik report is created. i used the report wizard and used an SqlDataSource as the data source. My select query contains a parameter:
SELECT ...
FROM ...
WHERE TableStudent.ID = @StudentID
The report also contains a parameter with the same name.
The constructor for the report is something like that:
public ReportStudent(int studentID)
{
InitializeComponent();
this.ReportParameters["StudentID"].Value = studentID;
this.StudentDataSource.Parameters[0].Value = studentID;
this.StudentDataSource.SelectCommand = this.StudentDataSource.SelectCommand.Replace("@StudentID", studentID.ToString());
}
Web app part:
In the web app which is going to view the report, i added a report viewer from the toolbox, but left the report property unassigned. In the web page, the user selects a student, then presses a button and the report for the selected student is viewed inside the report viewer.
The button click event code is as follows:
protected void ButtonReport_Click(object sender, EventArgs e)
{
if (Session["StudentID"] != null &&
!(((string)Session["StudentID"]).Trim().Equals("")))
{
ReportViewer viewer = (ReportViewer)this.ReportContent.Controls[0];
ReportStudent report = new ReportStudent(Int32.Parse((string)Session["StudentID"]));
viewer.Report = report;
viewer.RefreshReport();
}
}
The above scenario works perfectly..
When deploying to the remote server, change the connection strings accoringly in:
- Web.config of web app
- Settings.settings and app.config for the report library.
Besides, add the telerik libraries shown in the figure. (By the way, i am not sure if this list is minimal or not...)
and finally, here is telerik relevant portions of my
web.config:
<configuration>
<configSections>
<section name="Telerik.Reporting" type="Telerik.Reporting.Processing.Config.ReportingConfigurationSection, Telerik.Reporting, Version=6.0.12.215, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" allowLocation="true" allowDefinition="Everywhere" />
</configSections>
<Telerik.Reporting>
<Extensions>
<Render>
<Extension name="IMAGE" visible="false"></Extension>
<Extension name="HTML" visible="false"></Extension>
<Extension name="MHTML" visible="false"></Extension>
<Extension name="XLS" visible="false"></Extension>
<Extension name="CSV" visible="false"></Extension>
<Extension name="RTF" visible="false"></Extension>
</Render>
</Extensions>
</Telerik.Reporting>
...
<appSettings>
<add key="Telerik.Skin" value="Web20" />
<add key="Telerik.ScriptManager.TelerikCdn" value="Disabled" />
<add key="Telerik.StyleSheetManager.TelerikCdn" value="Disabled" />
</appSettings>
<system.web>
<pages>
<controls>
<add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" />
</controls>
</pages>
<compilation targetFramework="4.0">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="Telerik.ReportViewer.WebForms, Version=6.0.12.215, Culture=neutral, PublicKeyToken=A9D7983DFCC261BE" />
<add assembly="Telerik.Reporting, Version=6.0.12.215, Culture=neutral, PublicKeyToken=A9D7983DFCC261BE" />
</assemblies>
</compilation>
<httpHandlers>
<add path="ChartImage.axd" verb="*" type="Telerik.Web.UI.ChartHttpHandler"
validate="false" />
<add path="Telerik.Web.UI.SpellCheckHandler.axd" verb="*" type="Telerik.Web.UI.SpellCheckHandler"
validate="false" />
<add path="Telerik.Web.UI.DialogHandler.aspx" verb="*" type="Telerik.Web.UI.DialogHandler"
validate="false" />
<add path="Telerik.RadUploadProgressHandler.ashx" verb="*" type="Telerik.Web.UI.RadUploadProgressHandler"
validate="false" />
<add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource"
validate="false" />
<add path="Telerik.ReportViewer.axd" verb="*" type="Telerik.ReportViewer.WebForms.HttpHandler, Telerik.ReportViewer.WebForms, Version=6.0.12.215, Culture=neutral, PublicKeyToken=a9d7983dfcc261be"
validate="true" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers>
<remove name="ChartImage_axd" />
<add name="ChartImage_axd" path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" preCondition="integratedMode" />
<remove name="Telerik_Web_UI_SpellCheckHandler_axd" />
<add name="Telerik_Web_UI_SpellCheckHandler_axd" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" preCondition="integratedMode" />
<remove name="Telerik_Web_UI_DialogHandler_aspx" />
<add name="Telerik_Web_UI_DialogHandler_aspx" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" preCondition="integratedMode" />
<remove name="Telerik_RadUploadProgressHandler_ashx" />
<add name="Telerik_RadUploadProgressHandler_ashx" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" preCondition="integratedMode" />
<remove name="Telerik_Web_UI_WebResource_axd" />
<add name="Telerik_Web_UI_WebResource_axd" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" preCondition="integratedMode" />
<add name="Telerik.ReportViewer.axd_*" path="Telerik.ReportViewer.axd" verb="*" type="Telerik.ReportViewer.WebForms.HttpHandler, Telerik.ReportViewer.WebForms, Version=6.0.12.215, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" preCondition="integratedMode" />
</handlers>
</system.webServer>
</configuration>