The source of the report definition has not been specified(RDLC)

=================

The source of the report definition has not been specified

原因缺少:ReportViewer1.LocalReport.ReportPath = reportPath

=================

动态装载Report(RDLC文件)

An error has occurred because a control with id 'ctl09$ctl00$ctl07$ctl00' could not be located or a different control is assigned to the same ID after postback. If the ID is not assigned, explicitly set the ID property of controls that raise postback events to avoid this error.

原因:

After some digging, I determined the error was due to multiple asp:ButtonField controls being placed in the GridView.  Since you can not assign an ID to these controls the above error was being raised.  I did not find out exactly why, but at a higher level, the issue was due to my master page having view state disabled.  Once I changed this so my master page had ViewStateEnabled="true" (I had previously set it to false) the error went away.  If you have viewstate turned off at the page or gridview level you may also encounter this issue.

---------------------------

Internal error: ClientID reference before OnInit

Line 131: cc.AddAt(prevIndex, ReportViewer1)

---------------------------

"EnableViewState Property of grid is by default 'TRUE' when i change it to 'FALSE' it becomes functional."

=================

When I reload the page, I get the following error.
"An error occurred because a control with auto-generated id '_ctl103' could not be located to raise a postback event. To avoid this error, explicitly set the ID property of controls that raise postback events.
I have a number of DropDownLists, some of them I add items dynamically at run time. Is it something that I have to set an ID for each items in the list box?

---------------------------

Try adding Trace="True" to the @Page directive at the top of your page. Then load your page and look at the control tree displayed at the bottom of the page; this should help you identify which control(s) are having their IDs set implicitly.
It's not normal for all server controls to cause automatic postbacks -- textboxes and dropdownlists, for example, should only cause a postback if their autopostback property is set to True -- but all hyperlinks and buttons (including imagebuttons) do cause a postback when clicked.

---------------------------

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       If Not Page.IsPostBack Then
            'btnGenerateReport_Click(sender, e) , Remove “btnGenerateReport_Click(sender, e) ” WORKS.
        End If
End Sub

Protected Sub btnGenerateReport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGenerateReport.Click
       Dim reportPath As String
        If  Me.chk.Checked Then
            reportPath = "Reports\a.rdlc"
        Else
            reportPath = "Reports\b.rdlc"
        End If

        Dim cc As ControlCollection = ReportViewer1.Parent.Controls
        Dim prevIndex As Integer = cc.IndexOf(ReportViewer1)
        cc.Remove(ReportViewer1)
        ReportViewer1 = New Microsoft.Reporting.WebForms.ReportViewer()
        cc.AddAt(prevIndex, ReportViewer1)

        'Get Data into dataset
        Dim thisDataSet As System.Data.DataSet = New System.Data.DataSet()
        thisDataSet = …..

        Dim datasource As ReportDataSource = New ReportDataSource("uspXXX", thisDataSet.Tables(0))

        'Displayed in ReportVierer
        ReportViewer1.LocalReport.DataSources.Clear()
        ReportViewer1.LocalReport.ReportPath = reportPath
        ReportViewer1.LocalReport.DataSources.Add(datasource)
        ReportViewer1.LocalReport.Refresh()

    End Sub

---------------------------

Something connected to _ctl8 is not being set in page load, thus the
controls events dont exist - in theory the control does not exist. It can
be connected to viewstate not being present for the control, sometimes
because of caching and thus not passing the correct information back in the
aspx postback - usually because oif dynamically generated controls that will
accept postback events requiring an ID thats not there.
The warning is telling you what the solution probably is - make sure you
explicitely set the ID.

---------------------------

动态创建控件的代码不能放到PageLoad事件中,而要放到PagePrerender事件中。

REF:

http://www.xmlpitstop.com/NewsGroups/readpost.aspx?MessageID=%3CeZg96DoeFHA.2584%40tk2msftngp13.phx.gbl%3E&NewsGroup=microsoft.public.dotnet.framework.aspnet&GroupID=9

原文地址:https://www.cnblogs.com/emanlee/p/1544412.html