Lezione 4: Aggiornamento della definizione del report a livello di programmazione
Data creazione: 17 luglio 2006
Dopo aver caricato la definizione del report dal server di report e aver definito un riferimento alla definizione mediante il campo del report, è necessario aggiornare la definizione del report. Per questo esempio verrà aggiornata la proprietà Description per il report.
Per aggiornare la definizione del report
Sostituire il codice per il metodo UpdateReportDefinition() nel file Program.cs (Module1.vb per Visual Basic) con il codice seguente:
private void UpdateReportDefinition() { System.Console.WriteLine("Updating Report Definition"); // Create a list of the Items Choices for the Report. The // ItemsChoiceType37 enum represents all the properties // available in the report and the ItemsElementName // represents the properties that exist in the current // instance of the report. List<ItemsChoiceType37> _reportItems = new List<ItemsChoiceType37>(_report.ItemsElementName); // Locate the index for the Description property int index = _reportItems.IndexOf( ItemsChoiceType37.Description); System.Console.WriteLine("- Old Description: " + _report.Items[index]); // Update the Description for the Report _report.Items[index] = "New Report Description"; System.Console.WriteLine("- New Description: " + _report.Items[index]); }
Private Sub UpdateReportDefinition() System.Console.WriteLine("Updating Report Definition") 'Create a list of the Items Choices for the Report. The 'ItemsChoiceType37 enum represents all the properties 'available in the report and the ItemsElementName 'represents the properties that exist in the current 'instance of the report. Dim reportItems As List(Of ItemsChoiceType37) = _ New List(Of ItemsChoiceType37)(m_report.ItemsElementName) 'Locate the index for the Description property Dim index As Integer = _ reportItems.IndexOf(ItemsChoiceType37.Description) System.Console.WriteLine("- Old Description: " & _ m_report.Items(index)) 'Update the Description for the Report m_report.Items(index) = "New Report Description" System.Console.WriteLine("- New Description: " & _ m_report.Items(index)) End Sub
Lezione successiva
Nella lezione successiva la definizione del report aggiornata verrà salvata nel server di report. Vedere Lezione 5: Pubblicazione della definizione del report nel Server report.
Vedere anche
Attività
Esercitazione: Aggiornamento dei report mediante le classi generate dallo schema RDL