powered by simpleCommunicator - 2.0.59     © 2025 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Отчетные системы [игнор отключен] [закрыт для гостей] / ReportViewer установка параметров
2 сообщений из 2, страница 1 из 1
ReportViewer установка параметров
    #35133080
Фотография Va1entin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Есть страничка с контролом 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
ReportViewer установка параметров
    #35133283
Фотография Va1entin
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Помогло
Код: plaintext
1.
if (this.ReportViewer1.LocalReport.IsDrillthroughReport)
      ReportViewer1.PerformBack();
Но это обходное решение. Вопрос открыт.

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


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