I've got a dataset and I only want to use a few records in a sub-report. I created a clone and added the records. I output using XMLWrite and got the expected records set. I then made the clone the source for the sub-report. When the report displays it's using the full recordset from the source dataset object. Why?
Here's the code that creates the clone:
Private Sub getDsClone(ByRef inClone As DataSet, ByVal matchStr As String, ByRef outClone As DataSet) | |
Dim i As Integer |
outClone = inClone.Clone | |
Dim dv As DataView = inClone.Tables(0).DefaultView | |
dv.RowFilter = matchStr | |
Dim dt As New DataTable | |
dt = dv.ToTable | |
For i = 0 To dv.Count - 1 | |
outClone.Tables(0).ImportRow(dv.Item(i).Row) | |
Next | |
End Sub |
And here's where I call the clone and attach it to the sub-report:
getDsClone(dsCrimeCount, "crime_classification_id = 3 and crime_type like ('%Drug%')", dsDrugCounts) | |
dsDrugCounts.WriteXml(xmlPath + "\dsDrugCounts.xml", XmlWriteMode.WriteSchema) | |
mySubObj = mySection.ReportObjects("Subreport5") | |
mySubRep = mySubObj.OpenSubreport(mySubObj.SubreportName) |
The dataset associated with the sub-report has not been used previously. That brings up another question. Is it possible to re-use a sub-report. That is, can I have the same sub-report associated with different datasets? Will the binding create separate instances?