I have an (rdlc) report which contains a subreport within a table. For each instance of the subreport that is generated the LocalReport.SubreportProcessing event is fired, which is in agreement with the documentation.
However for each of these events, it appears that only the first DataTable assigned is used within the report. I can verify that ReportFactory.ReturnNextDataTable is returning the appropriate DataTable for each row, but it appears the first instance of the DataTable is being repeated multiple times.
I've tried clearing out the report DataSources for each call (using e.DataSources.Clear()) but this makes no difference.
Here is my code:
void AddData(object sender, SubreportProcessingEventArgs e)
{
DataTable merged = ReportFactory.ReturnNextDataTable;
e.DataSources.Add(new ReportDataSource("RATES", merged)); //Subsequent DataTables ignored
}
I can't help feeling I'm going about this fundamentally the wrong way. Any ideas?
I've found the solution :
http://social.msdn.microsoft.com/Forums/es-PY/sqlreportingservices/thread/04f72cea-caea-48c5-82e9-f6b2b962717d
For me, the problem occurs after the migration from Report Viewer 9.0 (2008) to Report Viewer 11.0 (2012).
In continuation to the answer of Stephane CLARISSE here is the extract from the source
After some poking around and tinkering with my code, I found a workaround. The solution is to create a dummy parameter in the subreport, which you then need to bind to a field in the tablix dataset. Any field will do as long as both the subreport parameter and the tablix dataset field are type-compatible. You don't have to do anything with the parameter in the subreport, but now SSRS displays multiple instances of the same subreport, a separate one for each row in the tablix.
This seems to be a bug in SSRS and the workaround is to create a dummy paramaeter with any data type that is passed from the main report. Here is how it solved the problem for me
I added a dummy parameter in the subreport
on the main report, I just passed any field for the dummy parameter that matches with the datatype of the dummy parameter. In my case, it is integer (eventID)
Related
I have two datasets I need to pull from, A base that both reports use and then a separate one that only one report pulls from. I get the error
Error 12 The Value expression for the text box ‘Textbox9’ refers to
the field ‘Name’. Report item expressions can only refer to fields
within the current dataset scope or, if inside an aggregate, the
specified dataset scope.
My best guess is I have to associate them with the correct dataset but I have not been able to find any documentation on this.
edit: I am trying to access property files that I created for the fields on the report document.
Can someone please tell me where in the rdlc document I need to code something like name.value, "dataset1" or something similar?
When you create a table in a RLDC, in the Tablix properties (selecting a row or a column) you must associate a DataSet.
After doing that, you have to write in each cell the name of the field (in the dataset) that you will use. You can do that by clicking on the "little table" in the cell, when you put the mouse over it
In images (with Visual Studio 2010)
If you don't see the dataset in the list, you must add it.
For that, click on view menu -> report data.
Then, in the DummyDataSource, click Add Dataset..
And select it from the list, or create a new one instead, in the same form.
If this doesn't work, well I don't know haha
If the two datasets has the same structure, then you could use one just, and in the code assign it to the datasource
I ran into this same error and the only way I could resolve it was by closing and reopening BIDS and then refreshing the fields from the stored procedure (Right click the data set -> Dataset Propoerties -> Query -> Refresh Fields).
Thanks for the troubleshooting tips!
If you are trying to embed the results of one set into a table that is using another data set, have you considered a subreport?
After some careful research and error checking I found that I had to create my base model property file and when I drag the actual data points on to my form I had to associate them with their correct set:
I clicked the value and associated the correct dataset.
In my windows form I have to create a table (at runtime) of specified by the user name (in textbox) and then use this table as datasource of DataGridView. Finally, the filled table must be inserted into the database. I tried to solve this problem in two ways:
I have created a DataTable, specified its columns etc. but I couldn't insert the DataTable into the database, even using SqlDataAdapter.Update() - propably I misused DataAdapter. I'm working with C# for 1 week and I don't fully understand the idea of DataSets, TableAdapters etc. So I decided to use SQL commands.
Using ExecuteNonQuery() I've created table in my database, then I recognized, that I have to use magic SqlDataAdapter and I gave up.
I want to manage the content of DataGridView in the same way, as in the case of DataTable added to DataSet using configuration wizard.
I know, that I can skip DataGridView, create list of textboxes, button expanding this list, and function inserting all fields into my table after confirmation button, but my supervisor expects DataGridView.
I can't paste the code here, because I left only copy of source code on company computer. If it will be necessary I will paste here my code tomorrow.
try to use the method either RowValidating or CellValidating of DataGridView
private void dataGridViewEnterTab1_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
{
if (dataGridViewEnterTab1.IsCurrentRowDirty) // Trigger when the row is dirty or has changed
{
string userName = dataGridViewEnterTab1["UserNameCol", e.RowIndex].EditedFormattedValue.ToString();
//...Your SqlDataAdapter or codes
}
}
I hope it will help this idea. :)
I am new to RDLC reports in Visual Studio 2010.
I am working on a Website, in this I have used report feature of VS2010. I use ReportViewer to show Report1.rdlc. It is showing it perfectly. Now my requirement is to filter data in report at runtime. I go through this question but not able to understand it's answer.
Because Report1.rdlc is not available in code behind.
Now, how can I filter report's data at runtime?
Surely you assign the dataset to the rdlc report, and in the page of your reportviewer, you would be using an object datasource (and therefor an XSD dataset with datatables), which encapsulates the query.
The query naturally has a where clause, in which you insert your parameters to filter the data by, like:
WHERE (Table.Field = #Param OR #Param = A_Default_Value)
Now add the controls you like to the page before calling the report (drop-down lists, textboxes, etc..), those controls filter the Object datasource, which is mapped to a dataset in the rdlc report, and thus, the report would be filterd upon clicking on a certain button, e.g. Show Report, to refresh the object datasources (databinding them) and re-showing the report in the reportviewer.
You may consider assiging the values of the filtering controls to parameters in the rdlc, so that you may show the parameters of the report in its header upon generating it:
Parameters!ParameterName.Value
Hope that helps you.
How are you getting the data from Server, etc. Are you binding to a datatable result? If so, you can just have your query apply the filter when extracting data to begin with so you don't have to do anything special in the actual report.
Per your feedback, if you are getting a DataTable, then applying a filter should be easy like
DataTable oDT = YourSQLCommandToGetData();
oDT.DefaultView.RowFilter = "SomeColumn = x and OtherColumn = y";
And then run your report. If you want to take it to another level and ENSURE you don't have any unwanted records, you could even do something like
DataTable oNewFilteredResult = oDT.DefaultView.ToTable();
Then, you can assign the NEW table to call the RDLC.
Using Rdlc.
Always getting First Record repeatedly, i used
=First(Fields!emp_address.Value, "emp_management_systemDataSet_employee")
When I removing First then showing error.
If you have dragged a Table into your rdlc interface, and assigned a datasource to the table, all you need should be
=Fields!emp_address.Value
Have you tried :
=IIf(Fields!emp_address.Value, "emp_management_systemDataSet_employee")
In my application I have a report with one subreport contained inside a table cell. Within the SubreportProcessing event handler I supply a different set of data foreach instance of the subreport. In VS 2008 this worked okay. However, when I switched over to VS2010 and upgraded the report file format, the behavior changed. All subreport instances in the master table now contain the data that I supplied for the first table row. My code looks like this
void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
{
// _index is a global variable that is reset to zero in the DataBind procedure.
Trip currentTrip = _trips[_index];
e.DataSources.Add(new ReportDataSource("DataSourceName", currentTrip.Items));
_index++;
}
Is this the intended behavior? How can I now supply different datasets for multiple instances of the same subreport inside a table?
Thanks in advance.
Vladislav
After some poking around and tinkering with my code, I found a workaround. The solution is to create a dummy parameter in the subreport, which you then need to bind to a field in the tablix dataset. Any field will do as long as both the subreport parameter and the tablix dataset field are type-compatible. You don't have to do anything with the parameter in the subreport, but now SSRS displays multiple instances of the same subreport, a separate one for each row in the tablix.
Hope this will be helpful for someone else, too.
Vladislav