Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • Hi,

                                    I've studied the documentation/help on creating web based reports using the XtraReports Suite. It think the Suite is great but the the data binding is not as straight forward as i would like (in win forms you can bind your report to a data source but you cannot in asp.net...you suggest a dataaset).

                                    Data sets are messy and has other problems (i won't go into it) but you can easily create a dataset from a connection ...again problems. So what i want to do is do it manually in code. the code i am attempting to use is below. can you tell me why this does not work....your documentation implies it should.

                                    '***********************************************************************
                                    oCommand.CommandText = "spGetOpenLeads"
                                                oDataAdapter.SelectCommand = oCommand
                                                oDataAdapter.Fill(oDataSet, "ActiveLeads")

                                                ' bind dataset to report
                                                Dim oReport As New xrFromScratch
                                                oReport.DataSource = oDataSet
                                                oReport.DataMember = "ActiveLeads"

                                                Dim oDataBinding As New DevExpress.XtraReports.UI.XRBinding("Text", oDataSet, "ActiveLeads.Name")
                                                oReport.cel1.DataBindings.Add(oDataBinding)
                                                oReport.lblName.DataBindings.Add("Text", oDataSet, "ActiveLeads.Name")

                                                oReport.ShowPreview()

                                    '***********************************************************************************************

                                0

                                Hello Dave.

                                Thank you for your message. Please modify your code as follows:

                                	
                                [VB.NET]
                                Dim oDataBinding As New DevExpress.XtraReports.UI.XRBinding("Text", oDataSet.Tables("ActiveLeads"), "Name") oReport.cel1.DataBindings.Add(oDataBinding) oReport.lblName.DataBindings.Add("Text", oDataSet.Tables("ActiveLeads"), "Name")
                                We look forward to your feedback once you have had the opportunity to try our solution.

                                Best regards,
                                Ingvar.

                                0

                                hi Ingvar,

                                Thanks for your quick response. i modified the code as suggested but no data appears in the controls. can you provide another solution. BTW, the label and the table cells were added to the report from the toolbar and the only property set was the name....is there anything else i should be doing?

                                it would make sense fro this to work.

                                0

                                Hi Dave,

                                Thank you for your response. When the main report datasource is initialized, you can skip the 'DataSource' value when initializing the XRBinding instance, e.g.:

                                Dim oDataBinding As New DevExpress.XtraReports.UI.XRBinding("Text", Nothing, "Name")

                                If this does not help, provide a small sample project where the problematic report layout is included. See also:

                                How to dynamically produce a web report using the SQL query with parameters as data source.

                                Thanks,
                                Alex

                                0

                                Hi Team,

                                after reviewing the example on how to dymaically create a report...i was able to get everything working. However, two big questions remain unanswered. 1. Unless i specify the report name in design mode, i cannot get any part of the report to show up....not sure why if i'm doing it in code. 2. Why can't i put the code to set the report control properties in the web page load event...it only seems to work in the constructor event for the report (as in the example).

                                My aspx and code behind is included below...this is all the code in the report so you have it all....any clues?

                                This code is a TOTAL HACK JUST AS A PROOF OF CONCEPT.. ... so please forgive me for how messy it is

                                aspx..................

                                <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
                                    <dx:ReportToolbar ID="ReportToolbar1" runat='server'
                                    ShowDefaultButtons='False' ReportViewerID="rvActivityDetail">
                                        <Items>
                                            <dx:ReportToolbarButton ItemKind='Search' />
                                            <dx:ReportToolbarSeparator />
                                            <dx:ReportToolbarButton ItemKind='PrintReport' />
                                            <dx:ReportToolbarButton ItemKind='PrintPage' />
                                            <dx:ReportToolbarSeparator />
                                            <dx:ReportToolbarButton Enabled='False' ItemKind='FirstPage' />
                                            <dx:ReportToolbarButton Enabled='False' ItemKind='PreviousPage' />
                                            <dx:ReportToolbarLabel ItemKind='PageLabel' />
                                            <dx:ReportToolbarComboBox ItemKind='PageNumber' Width='65px'>
                                            </dx:ReportToolbarComboBox>
                                            <dx:ReportToolbarLabel ItemKind='OfLabel' />
                                            <dx:ReportToolbarTextBox IsReadOnly='True' ItemKind='PageCount' />
                                            <dx:ReportToolbarButton ItemKind='NextPage' />
                                            <dx:ReportToolbarButton ItemKind='LastPage' />
                                            <dx:ReportToolbarSeparator />
                                            <dx:ReportToolbarButton ItemKind='SaveToDisk' />
                                            <dx:ReportToolbarButton ItemKind='SaveToWindow' />
                                            <dx:ReportToolbarComboBox ItemKind='SaveFormat' Width='70px'>
                                                <Elements>
                                                    <dx:ListElement Value='pdf' />
                                                    <dx:ListElement Value='xls' />
                                                    <dx:ListElement Value='xlsx' />
                                                    <dx:ListElement Value='rtf' />
                                                    <dx:ListElement Value='mht' />
                                                    <dx:ListElement Value='html' />
                                                    <dx:ListElement Value='txt' />
                                                    <dx:ListElement Value='csv' />
                                                    <dx:ListElement Value='png' />
                                                </Elements>
                                            </dx:ReportToolbarComboBox>
                                        </Items>
                                        <Styles>
                                            <LabelStyle>
                                                <Margins MarginLeft='3px' MarginRight='3px' />
                                            </LabelStyle>
                                        </Styles>
                                    </dx:ReportToolbar>
                                    <dx:ReportViewer ID="rvActivityDetail" runat="server">
                                    </dx:ReportViewer>
                                    
                                </asp:Content>

                                code behind ................

                                    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
                                        Dim sErrorMessage As String = String.Empty

                                        If IsPostBack Or IsCallback Then Exit Sub

                                        Try

                                            Dim oReport As New xrActivityDetailReport
                                            oReport.lblHeader.Text = "Changed in code of form load event"

                                            ' ***************** Code that should be in constructor

                                            Dim oDataSet As New DataSet
                                            Dim oDataAdapter As New SqlDataAdapter

                                            Dim oConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("TopBuilder.My.MySettings.dbTopBuilder").ConnectionString.ToString)
                                            oConnection.Open()

                                            Dim oCommand As New SqlCommand
                                            oCommand.CommandType = CommandType.StoredProcedure
                                            oCommand.Connection = oConnection

                                            'open leads
                                            oCommand.CommandText = "spGetOpenLeads"
                                            oCommand.Parameters.Add(New SqlParameter("@BuilderAccountId", 1))
                                            oCommand.Parameters.Add(New SqlParameter("@UserEmployeeId", 1))
                                            oDataAdapter.SelectCommand = oCommand
                                            oDataAdapter.Fill(oDataSet, "ActiveLeads")

                                            ' bind dataset to report

                                            Dim sColunmName As String = oDataSet.Tables("ActiveLeads").Columns("Name").ColumnName
                                            Dim oDataBinding As New DevExpress.XtraReports.UI.XRBinding("Text", oDataSet, oDataSet.Tables("ActiveLeads").Columns("Name").ColumnName)
                                            oReport.tc1.DataBindings.Add(oDataBinding)
                                            oReport.tc1.Text = sColunmName

                                            If oDataSet.Tables("ActiveLeads").Rows.Count = 0 Then
                                                oReport.lblHeader.Text = "There are no rows returned"
                                            End If

                                            oReport.lbl1.DataBindings.Add("Text", oDataSet, oDataSet.Tables("ActiveLeads").Columns("Name").ColumnName)
                                            oReport.lbl1.Text = "Name"

                                            oReport.lbl2.Text = "Changed in Code"

                                            oReport.DataSource = oDataSet
                                            oReport.DataMember = "ActiveLeads"

                                            If Not oConnection.State = ConnectionState.Closed Then oConnection.Close()

                                            '
                                            ' ***************** end constructor code ****************************************

                                            rvActivityDetail.Report = oReport

                                        Catch ex As Exception
                                            Dim smessage As String = ex.Message
                                        Finally
                                        End Try
                                    End Sub

                                0

                                Hi Dave,

                                Thank you for posting your code snippet. When initializing an XtraReport instance at runtime, it is required to perform this operation on every round-trip to the server. Therefore, you will need to update the Page_Load event handler and remove the 'If IsPostBack Or IsCallback Then Exit Sub' statement from it. If necessary, you can utilize the built-in ReportViewer caching mechanism: How to use the caching functionality of the Document Viewer.
                                 
                                Thanks,
                                Alex

                                0

                                Alex....you did it....thank you so much.

                                i have all the flexibility i now need to develop some awesome reports. i will look at the caching reference as well. thank you very much.

                                i will close the ticket.

                                0

                                see my last post

                                0

                                Hi Dave,

                                Thank you for the update. I am glad that my assistance was helpful. Please feel free to contact us if you have any further difficulties. We will do our best to help you.

                                Thanks,
                                Alex

                                To start a chat you should create a support ticket


                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners