I have a C# class that contains a collection property. I am showing this data in a sub report. In design editor I find that the collection property is not seen in the list of available columns. How can I show these values then ?
I solved the issue by using a string property and made a comma separated list of values present in the collection and assigning it to the string property.
Related
I have a report designed in RDLC that has a Dataset consisting of a set of integer UserID values. The report consists of a one-column table, with each row grouped by UserID. Inside each cell is a subreport generated from the UserID. The subreport is also designed in RDLC from two separate datasets, each of which is generated based on the UserID.
How do I design the subreport to generate the appropriate information for each Parent row's UserID?
I don't see how it can be done on the parent report side, as the method defined in SubreportProcessingEventHandler appears to be called just once, rather than once for each UserID's Subreport.
I assume it has to be done in the Subreport's ascx.cs file - but where would I put it? Is there a predetermined method name to use, or do I call the method from the parent somehow?
Is what I am describing even possible?
Apparently, the answer - at least, the one that works when I do it - is, the SubreportProcessingEventHandler is, in fact, called once for each UserID, so the UserID is passed to the handler as a parameter, and the subreport's data sets are built within the handler using that UserID.
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
=iif(Fields!SubjectCode.Value=Parameters!SubjectCode.Value,Fields!SpAbsentCount.Value,0)
I have a Main Report and a sub report
SubjectCode parameter is passed to the subreport from the main report
for each subject code sub report is generated. based on the subject code I need to select a single value(SpAbsentCount) to display on the sub report
something like select... from... where SubectCode=#SubjectCode
I tried the above expression but it doesn't work
Hard to say exactly without knowing the data and setup of your report, but one guess I have is that you have a whole set of values, and your IIF expression winds up looking at only the first row of values. Try creating a tablix or list that filters on the SubjectCode, then using your code.
I am using Visual Studio 2008 to build a base report that has 3 parameters representing different types of services for which I am displaying all the companies and their details that match those parameters in a tablix under each Textbox heading.
The problem is that I am displaying the value of selected parameter in each heading using the expression:
="SERVICE1: " & First(Fields!Service1.Value, "dsServices")
When the DataSet resultset returns no rows, the parameter part of the heading is empty but when row are returned, the heading is as I want it (ex: "SERVICE1: Some sub service category here"). I want the full heading to show up even if there are no rows to display. How do I retain all of the heading? for the record I am using NoRowsMessage property when I want the tablix to be hidden due to no rows returned. Again, I still want the headings with the values selected to appear.
I googled to no avail. Thank you for any tip you can suggest.
The reason why your heading is empty, when your dataset returns nothing is because in your expression you are referencing the first record in your "dsServices" dataset.
This is what your expression does : ="SERVICE1: " & First(Fields!Service1.Value, "dsServices")
In your question you mention you have 3 parameters...if you want to reference these parameters then rather include the parameter value in the expression. That expression would like something like this:
="SERVICE1: " & Parameters!Service1.Value)
I'm obviously assuming you have a parameter for each service type. If you do this then your expression no longer becomes dependent on your dataset.
I have a relatively simple Listview that suddenly needs (due to new requirements) to have it's 'layout' extracted to a DataTable so that a common routine can convert it to an Excel spreadsheet for export purposes.
The ItemTemplate is just a series of Table Rows with some text, data-bound labels and textboxes with validators in the cells.
Usually, when trying to pull out a particular value (like what was entered into a text box), I use the ListViewItem's .FindControl method.
For Each objItem As ListViewItem In lvwOptions.Items
Dim objTextHrsLabor As TextBox = CType(objItem.FindControl("txtHrsOptByLabor"), TextBox)
decHours = CDec(objTextHrsLabor.Text)
Next
In this case, however, I'm trying to take all the data displayed - all the 'rows and columns' of the table that was created.
Inside the ForEach / Next loop of ListViewItems, I started a ForEach/Next loop of Controls for each instance's controls but I got some really strange results returned (like controls that had a couple of table cells in them).
I get the sense I'm headed in the wrong direction. All I want is for the nicely-formatted 5-line, 6 column table to be converted to a 5-line, 6-column data table.
Is there another avenue I should be looking at?
I would look at the underlying data source for your ListView.
The data source must be a collection or an IEnumerable and you should be able to iterate through it to build your data table.
If you know that all elements are of the same type then you can use the first element and look at its properties using reflection to determine which columns your table should contain. Then you can add DataRows to your table and fill in the columns using the property names.
This will probably be faster than iterating through the generated html of the ListView.
I used this approach for exporting a ListView to Excel: http://aspalliance.com/771_CodeSnip_Exporting_GridView_to_Excel.
I know it deals with a GridView, but I adapted it to a ListView (as long as the underlying structure is a table) and it worked fine for me.
HTH.
you can use..
listView1.Items[0].SubItems[0].Text
this will be helpful , really simple and easy . You can extract info right on the basis of index & use anyway you want.