微软提供的水晶报表例子程序CS_ReducedCode_Parameters,default.aspx源码为:
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><%@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
    Namespace="CrystalDecisions.Web" TagPrefix="CR" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>51aspx.com Demo</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Select a city:&nbsp;
        <asp:DropDownList ID="cityList" runat="server">
            <asp:ListItem>Paris</asp:ListItem>
            <asp:ListItem>Tokyo</asp:ListItem>
        </asp:DropDownList>
        &nbsp; &nbsp;
        <asp:Button ID="redisplay" runat="server" Text="Redisplay Report" /><br />
        <br />
        <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True"
            Height="1039px" ReportSourceID="CrystalReportSource1" Width="901px" />
        <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
            <Report FileName="XtremeCustomers.rpt">
                <Parameters>
                    <CR:ControlParameter ControlID="cityList" ConvertEmptyStringToNull="False" DefaultValue=""
                        Name="City" PropertyName="SelectedValue" ReportName="" />
                </Parameters>
            </Report>
        </CR:CrystalReportSource>
    
    </div>
    </form>
   <a href="http://www.51aspx.com" target="_blank">Download From 51aspx.com</a> 
</body>
</html>
defult.aspx.cs程序为:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {    }
}
为什么按钮ID="redisplay"内无如何程序代码,当选择DropDownList ID="cityList"时,按此按钮时,也能使水晶报表更新?

解决方案 »

  1.   

     AutoDataBind="True" 
    是这个属性true的原因吧.
    感觉和AutoPostBack差不多,自动数据绑定.
      

  2.   

    我任意加了个按钮,都能刷新报表,真的可能是AutoDataBind="True" 是这个属性true的原因
      

  3.   

    重点是 ControlID="cityList" ,而不是 AutoDataBind="True" 
    <asp:Button ID="redisplay" runat="server" Text="Redisplay Report" /> 这个按钮主要是触发一个服务器回发事件
    CRViewer会自动去提取cityList控件的值返回给报表模板
      

  4.   


    请问一下.如果AutoDataBind="false",这个报表会自动刷新吗?ControlID="cityList",这个在这里是报表的一个参数吧,和LZ问的"按此按钮时,也能使水晶报表更新?"没有什么关系吧.