【发布时间】:2015-09-07 13:13:16
【问题描述】:
我在一个名为 WebForm1 的网络表单中有一个报表查看器,它使用两个名为 fromDate 和 toDate 的参数来过滤数据。 Web 表单在加载时显示数据。问题是,当我更改 fromDate、toDate 字段并单击 button1 提交时,它会返回默认日期并重新加载相同的数据。如何使用新的输入日期刷新 reportviewer 数据?如何在带有参数的 webform(不是 winform)中使用 reportviewer?谢谢你的帮助。
这是我的 WebForm1.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication2
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.fromDate.Text = "8/6/2015";
this.toDate.Text = DateTime.Now.ToShortDateString();
}
}
}
【问题讨论】:
-
你需要学习如何传递参数和刷新reportviewer。在 google 中查找如何将参数传递给报告查看器,这个 stackoverflow.com/questions/5103784/… 也可以帮助您。
-
@user1698255,当您单击按钮时,页面被加载,并且 fromdate 和 todate 字段填充了您在 page_load 方法中分配的值,所以它就是这样发生的,只需放置两行分配在 !IsPostBack 中就可以了,