Devexpress XtraReport - set query on filterstring - devexpress

I have a DexExpress XtraReport and I want to set the filterstring on condition below:
If user didn't select any parameter, report should show data in a month.
If user select driver and lorry No, report should show that driver and lorry at that month.
How should I set the filterstring to get the result above?
Devexpress XtraReport filterstring screenshot

Go through documentation: XtraReportBase.FilterString Property
You can Set this property in the following event handlers.
The DataSourceDemanded event.
The XRControl.BeforePrint event of a report.
You can also handle the XRControl.BeforePrint event of a specific
report band (e.g., the DetailBand). In this event handler, you can
access the current data row using the GetCurrentRow and
GetCurrentColumnValue methods and cancel printing of the band under a specific condition using the e.Cancel property.

Related

ASPX FormView data not displayed with valid data from datasource

I have an aspx Formview set to 'Edit' mode and a valid SQL datasource that returns the correct data row based on the row ID. These lines in my grid rowcommand event:
DailyDataSource.SelectParameters["ID"].DefaultValue = recid.ToString();
FormView1.DataBind();
DataRowView drv = (DataRowView)FormView1.DataItem;
returns a valid DataRowView object with the correct data record. However, the DataBind() appears to not be working - no data appears in the entry text boxes. Unless I set the entry textboxes to 'ReadOnly'. They then display the returned data, but I (obviously) cannot edit it.
I can edit and enter data in the non-readonly text boxes, and the Save command saves the data, and it displays in the gridview, but if I try to edit it, I again get a valid set of data, but no displayed data.
My question: Why is making these fields readonly allowing the data to be displayed?
Second question: Why is the data in the datasource returned record not appearing in the editable textboxes?
BLUF: I needed to do the formview data load in the PostBack event, in order to get the correct session variables which were set by other events. Question of "How can I be so dumb when I am so smart?"

XtraReport - get data from non-master datasource based on a parameter value

I want to get data from non-master datasource based on a parameter value.
Let's say we have 2 datasources in report:
* datasource1 - main dataprovider
* datasource2 - from which I need to get additional data
And also we have a report parameter, which is bound to the datasource2 to populate dropdown when report is opened.
I need that whenever user picks one of the option from parameter dropdown and submits, to grab corresponding item data from datasource2 and put in the report.
Is it possible? I didn't find any answer on the internet.
it will be possible if you leave single datasource but with two tables/datamembers,
for example DevExpress SqlDataSource may have number of Queries,
in the needed label you may write the expression
iif(Parameters.UseDefault, OptionalTable.DefaultValue, DataTable.ValueColumn)
is this helpful for your scenario?

DevExpress XtraReports binding subreport datasource to report's datasource of collection

I'm having some trouble with binding a DevExpress XtraReport subreport's datasource to it's containing report's datasource. The datasource is an object collection.
If I create a basic reports with sub detail sections all is well.
For example, the object collection is a list of companies. Each company has a list of addresses and a list of contacts. What I am attempting is to create a report with two subreports side-by-side for each (detail) company.
From several web articles, I thought this approach seemed like it would work:
report.ContactSubreport.ReportSource.DataSource = report.Datasource
which I call from a script using the subreport's BeforePrint event.
I also tried setting the datamember to the name of the sub collection:
report.ContactSubreport.ReportSource.DataMember = "Contacts"
Any help or suggestions would be greatly appreciated. Thanks!
From what I gather, you need to display only child collections' records that belong to the current master record.
In this case, it's better to handle the BeforePrint event of those XRSubreports and call there the XtraReport.GetCurrentRow method for a master report. This method call will return a master record (i.e., an instance of the "Company" object). This will allow you to pass the "Company.Addresses" list to the first subreport and the "Company.Contacts" list to the second one. Thus, the details that only correspond to each "Company" will be printed in both subreports.
I accomplish XtraSubReport dynamic or runtime data binding by doing Something like this and it WORKS perfectly
(VB.NET but can easily be implemented in C#)
NOTE:
The BandKind.Detail parameter below means the subreport was placed in the Detail Band. If not then specify the band of the main report where you placed the subreport in (eg. PageHeader, ReportHeader, PageFooter, etc)
The "XrSubreportInvoiceBank" is the name of the subReport that you created in the main report. You will need to change it to the name of the subreport in your main report
Dim MyDocument As New XtraReportInvoiceHardcopy
Dim BankSubreport As XRSubreport = CType(MyDocument.Bands(BandKind.Detail).FindControl("XrSubreportInvoiceBank", True), XRSubreport)
Dim BankAccount As DataTable = New DataTable 'You can put your Data in here
BankSubreport.ReportSource.DataSource = BankAccount
BankSubreport.Visible = True

How to select a date in Flex datechooser using TestComplete

We are testing a Flex application using TestComplete Tool. The tool is able to recognize all the fields inside the Flex application. As part of this, we need to select dates (DateChooser object) for few of the fields in a Form.
Issue: We are selecting the date in the datechooser object by setting the "selectedDate" property.
fromDate.FlexObject.selectedDate = aqDateTime.Today
The selected date appears in the UI for the fromDate field.On submitting the form, we are getting error message as "fromDate field is empty".
Do we need to set any additional fields to register the selected date?
We are using VBScript as scripting language in the Test Complete Tool.
The problem is that a required event is not fired when the value is set programmatically (e.g. OnKeyPress or something like that). You need to make your test type the date to the field in order to make this event work:
fromDate.FlexObject.selectedDate.Keys "6/2/2014"

Bind a Text Box to a Field Selected by SQLDataSource (VB.NET)

I'm looking for the easiest way to bind data from a SqlDataSource to textboxes dropped in Visual Studio 2008.
For example, I have 4 textboxes currently that have Address, City, State, Zip. I also have a SqlDataSource on the page fetching the ID of the record and selecting those 4 fields based on ID.
How am I able to quickly bind each box to those particular fields selected? I would think this would be really straight forward - but seems it's not. Seems like the answer is funneled towards having to create a GridView or some type of control.
Be gentle...I'm a nub :)
In general you are correct, if you want to use databinding you'll need to use an appropriate control. For this example I'd suggest using a FormView - it is designed to display the results from a single database record and uses templates, meaning you'll have complete control over the output. This article is probably a good place to start: FormView Control: Step by Step.
To read the values bound to the FormView in the code-behind class you would need to create an event handler for the FormView's DataBound event. In that event handler you would reference the controls programmatically via FindControl, like so:
Dim myLabel As Label = CType(FormViewID.FindControl("id"), Label)
Here, id would be the ID of the Label whose value you were interested in. Once you have a reference to the Label you can get its value using myLabel.Text.

Resources