I have a webform project on asp.net with c #, I work with web forms. I have added a Gridview to show the data of a SQL query and I want to show them in a crystal report. But it happens that when executing it does not appear and clicking the button does not show anything. Why will it be?
webconfig
<system.web>
<configuration>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="CrystalDecisions.Web, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.ReportAppServer.Controllers, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.ReportAppServer.DataDefModel, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="CrystalDecisions.ReportSource, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="CrystalDecisions.Shared, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</assemblies>
</compilation>
<httpRuntime/>
<httpHandlers>
<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
</httpHandlers>
<pages controlRenderingCompatibilityVersion="4.0"/>
</system.web>
<appSettings>
<add key="CrystalImageCleaner-AutoStart" value="true" />
<add key="CrystalImageCleaner-Sleep" value="60000" />
<add key="CrystalImageCleaner-Age" value="120000" />
</appSettings>
<connectionStrings>
<add name="cn" connectionString="Data bla bla" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers>
</system.codedom>
<system.webServer>
<handlers>
<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode"/>
</handlers>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.x"/>
</startup>
</configuration>
webform.aspx
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True" GroupTreeImagesFolderUrl="/aspnet_client/system_web/2_0_50727/CrystalReportWebF rmViewer3/images/tree/" ToolbarImagesFolderUrl="/aspnet_client/system_web/2_0_50727/CrystalReportWebFormViewer3/images/toolbar/" />
webform.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
FillGrid();
}
}
void FillGrid(){
SqlCommand cmd = new SqlCommand("SELECT * from table where cod_user='"+
Session["Cod_user"]+"'", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
gridview1.Visible = true;
gridview1.DataSource = dt;
gridview1.DataBind();
con.Close();}
protected void button_Click(object sender, EventArgs e)
{ DsRF ds = new DsRF(); //DsRF es el dataset lo cree agregando un nuevo elemento al proyecto y ahi mismo cree la tabla dt_RF
DataTable dt_RF = ds.Tables.Add("dt_RF");//aqui agrego la tabla al dataset
foreach (DataControlField column in gridview1.Columns)
{
dt_RF.Columns.Add(column.HeaderText, typeof(string));
}
foreach (GridViewRow dgr in gridview1.Rows)
{
dt_RF.Rows.Add(gridview1.Rows[0].Cells.Cast<TableCell>().Select(c => c.Text));
}
ReportDocument oRep = new ReportDocument();
oRep.Load(Server.MapPath("~/Proyecto/mycrystal.rpt"));
oRep.SetDataSource(ds);
CrystalReportViewer1.ReportSource = oRep; }}