简体   繁体   中英

Issue with asp.net report viewer binding

I have a problem with asp.net report viewer I have to display two SQL table data

I made a function for this that is working fine with html reporting but I wants to display this in report viewer in my website. the following code is working fine with Gridview but not binding with report viewer.

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        reports();
    }

}
private void reports()
{

    DataSet ds = new DataSet();
    DataTable da = new DataTable();
    DataColumn dc = new DataColumn();

    db.CommandTimeout = 200;
    var ans = (from data in db.tblAttributeDatas
               where data.nMainDataId == 3291
               select data).ToList();


    List<tblSectionAttribute> cols = (from Attrib in db.tblSectionAttributes
                                      from main in db.tblAttributeDatas
                                      where Attrib.nId == main.nSectionAttributeId
                                      &&
                                      main.nMainDataId == 3291
                                      select Attrib).ToList();
    int a = 1;
    foreach (var item in cols)
    {


        DataColumn dc1 = new DataColumn(a.ToString() + "." + item.strAttributeName);
        dc1.DefaultValue = "";
        da.Columns.Add(dc1);
        a++;



    }
    int row = 0;
    DataRow dr = da.NewRow();
    foreach (var item1 in ans)
    {

        DataColumn d = new DataColumn();
        if (item1.strValue != "")
        {
            d = new DataColumn(row.ToString() + "." + item1.strValue);
        }
        else
        {
            d = new DataColumn("not Answered");
        }
        dr[row] = d;
        //da.Rows.Add(dr);
        //   dr = da.Rows[row];

        row++;
    }
    da.Rows.Add(dr);
    ReportViewer1.ProcessingMode = ProcessingMode.Local;
    ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");

    ReportDataSource datasource = new ReportDataSource("DataSet",da);
    ReportViewer1.DataBind();
    ReportViewer1.LocalReport.DataSources.Clear();
    ReportViewer1.LocalReport.DataSources.Add(datasource);



}

and my aspx code is

     <asp:ScriptManager runat="server" />
    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
        <LocalReport ReportPath="Report.rdlc">
       <DataSources>
            <rsweb:ReportDataSource  />     
       </DataSources>
        </LocalReport>
    </rsweb:ReportViewer>

and output is blank only blank ReportViewer display in browser with Report Viewer built-in heading and paging no error just black output of Report Viewer please help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM