Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Отчетные системы [игнор отключен] [закрыт для гостей] / ReportViewer установка параметров / 2 сообщений из 2, страница 1 из 1
14.02.2008, 15:08
    #35133080
Va1entin
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
ReportViewer установка параметров
Есть страничка с контролом ReportViewer.
Заполняю его:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
private void ViewReport()
  {
    this.ReportViewer1.ProcessingMode = ProcessingMode.Local;
    this.ReportViewer1.LocalReport.ReportPath = @"Reports/MyReport.rdl";
    this.ReportViewer1.LocalReport.Refresh();

    DataSet ds;
    SqlParameter[] params_ = new SqlParameter[ 3 ];
    params_[ 0 ] = new SqlParameter("Param1", SqlDbType.Int);
    params_[ 0 ].Value = int.Parse(ddlParam1.SelectedItem.Value);
    params_[ 1 ] = new SqlParameter("FromDate", SqlDbType.DateTime);
    try
    {
      params_[ 1 ].Value = DateTime.Parse(tbDateFrom.Text);
    }
    catch
    {
      params_[ 1 ].Value = DateTime.Today.AddYears(- 1 );
    }
    params_[ 2 ] = new SqlParameter("ToDate", SqlDbType.DateTime);
    try
    {
      params_[ 2 ].Value = DateTime.Parse(tbDateTo.Text);
    }
    catch
    {
      params_[ 2 ].Value = DateTime.Today;
    }
    ds = DBUtils.ExecuteProc("MY_REPORT", params_);
    ReportViewer1.LocalReport.DataSources.Clear();
    ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("MyDataSource", ds.Tables[ 0 ]));

    System.Collections.Generic.List<ReportParameter> params__ = new System.Collections.Generic.List<ReportParameter>();
    params__.Add(new ReportParameter("Param1", ddlParam1.SelectedItem.Value));
    params__.Add(new ReportParameter("FromDate", tbDateFrom.Text));
    params__.Add(new ReportParameter("ToDate", tbDateTo.Text));
    ReportViewer1.LocalReport.SetParameters(params__);
  }
код отрабатывает
выполняю погружение
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
protected void ReportViewer1_Drillthrough(object sender, DrillthroughEventArgs e)
  {
    LocalReport localreport = (LocalReport)e.Report;

    localreport.DataSources.Clear();
    DataSet ds = null;

    localreport.ReportPath = @"Reports/MyReportDD.rdl";

    SqlParameter[] params_ = new SqlParameter[ 1 ];
    params_[ 0 ] = new SqlParameter("Param", SqlDbType.Int);
    params_[ 0 ].Value = int.Parse(e.Report.GetParameters()[ 0 ].Values[ 0 ].ToString());
    ds = DBUtils.ExecuteProc("MY_REPORT_DD", params_);

      localreport.DataSources.Add(new ReportDataSource("MYDataSource", ds.Tables[ 0 ]));

    localreport.Refresh();
  }
тоже отрабатывает, выводит погружение
но когда вызываю еще раз функцию ViewReport вылетает ошибка при установке параметров
отчета. (на строке ReportViewer1.LocalReport.SetParameters(params__);)
Отладчиком вызываю GetParameters() и вижу параметр отчета погружения.
Видимо, this.ReportViewer1.LocalReport.Refresh() не производит сброс параметров.
Вопрос: как инициализировать контрол ReportViewer, чтобы можно было вывести
главный отчет (до погружения)?
...
Рейтинг: 0 / 0
14.02.2008, 15:46
    #35133283
Va1entin
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
ReportViewer установка параметров
Помогло
Код: plaintext
1.
if (this.ReportViewer1.LocalReport.IsDrillthroughReport)
      ReportViewer1.PerformBack();
Но это обходное решение. Вопрос открыт.

Posted via ActualForum NNTP Server 1.4
...
Рейтинг: 0 / 0
Форумы / Отчетные системы [игнор отключен] [закрыт для гостей] / ReportViewer установка параметров / 2 сообщений из 2, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]