4단원: 프로그래밍 방식으로 보고서 정의 업데이트
이제 보고서 서버에서 보고서 정의가 로드되었고 보고서 필드를 사용하여 해당 정의를 참조했으므로 보고서 정의를 업데이트해야 합니다. 이 예에서는 보고서의 Description 속성을 업데이트합니다.
보고서 정의를 업데이트하려면
Program.cs 파일(Visual Basic의 경우 Module1.vb)에서 UpdateReportDefinition() 메서드의 코드를 다음 코드로 바꿉니다.
private void UpdateReportDefinition() { System.Console.WriteLine("Updating Report Definition"); // Create a list of the Items Choices for the Report. The // ItemsChoiceType80 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<ItemsChoiceType80> _reportItems = new List<ItemsChoiceType80>(_report.ItemsElementName); // Locate the index for the Description property int index = _reportItems.IndexOf( ItemsChoiceType80.Description); // The Description item is of type StringLocIDType, so // cast the item type first and then assign new value. System.Console.WriteLine("- Old Description: " + ((StringLocIDType)_report.Items[index]).Value ); // Update the Description for the Report ((StringLocIDType)_report.Items[index]).Value = "New Report Description"; System.Console.WriteLine("- New Description: " + ((StringLocIDType)_report.Items[index]).Value ); }
Private Sub UpdateReportDefinition() System.Console.WriteLine("Updating Report Definition") 'Create a list of the Items Choices for the Report. The 'ItemsChoiceType80 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 ItemsChoiceType80) = _ New List(Of ItemsChoiceType80)(m_report.ItemsElementName) 'Locate the index for the Description property Dim index As Integer = _ reportItems.IndexOf(ItemsChoiceType80.Description) 'The Description item is of type StringLocIDType, so 'cast the item type first and then assign new value. System.Console.WriteLine("- Old Description: " & _ DirectCast(m_report.Items(index), StringLocIDType).Value) 'Update the Description for the Report DirectCast(m_report.Items(index), StringLocIDType).Value = _ "New Report Description" System.Console.WriteLine("- New Description: " & _ DirectCast(m_report.Items(index), StringLocIDType).Value) End Sub