有以下内容来加载报表查看器,但问题是控件没有显示数据。我创建了一个数据表然后,我创建了一个数据集并将数据表添加到数据集中,以使数据集成为reportviewer的源。此外,我已经获得了一个xml文件,以防万一我可以将其添加为reportviewer的来源(以防它可能)或者是否有更好的解决方案来解决我的问题?
public DataTable ListarMenuDataTable()
{
using (OleDbConnection cn = new OleDbConnection(ConfigurationManager.ConnectionStrings["App"].ToString()))
{
OleDbDataAdapter da = new OleDbDataAdapter("SELECT NombreNodo, IdentificadorNodo, IdentificadorPadre,Formulario FROM Menu", cn);
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
}
private void rbClientes_CheckedChanged(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt = this.oClienteDAO.ListarMenuDataTable();
dt.TableName = "dtMenu";
DataSet dsMenu = new DataSet();
dsMenu.Tables.Add(dt);
if (System.IO.File.Exists(System.AppDomain.CurrentDomain.BaseDirectory + "\\Recursos\\Reportes\\Xml_" + rbClientes.Text + ".xml") == false)
{
dsMenu.WriteXml(System.AppDomain.CurrentDomain.BaseDirectory + "\\Recursos\\Reportes\\Xml_" + rbClientes.Text + ".xml", XmlWriteMode.WriteSchema);
}
this.reportViewer1.ProcessingMode = ProcessingMode.Local;
this.reportViewer1.LocalReport.ReportPath = System.AppDomain.CurrentDomain.BaseDirectory + "\\Recursos\\Reportes\\Rpt_" + rbClientes.Text + ".rdlc";
this.reportViewer1.LocalReport.DataSources.Clear();
ReportDataSource source = new ReportDataSource("dtMenu",dsMenu.Tables[0]);
reportViewer1.LocalReport.DataSources.Add(source);
this.reportViewer1.RefreshReport();
}