下拉不是AutoPostBack'ing

时间:2012-05-09 22:50:58

标签: asp.net

我有一个包含报告名称的下拉列表。选择报表后,它会使用所选报表加载Crystal Report Viewer。在开发环境中,这很好用。在制作中,它似乎并没有发布回来。不确定这是否真的是问题,但此时我才知道这一点。

这是选择项目时应该运行的代码:

   protected void ReportDropDown_SelectedIndexChanged(object sender, EventArgs e)
    {
        MessagesTextBox.Text = "ReportDropDown Index Changed";
        try
        {
            var rptName = ReportDropDown.SelectedValue.ToString();
            MessagesTextBox.Text = rptName;

            if (!Data.Reports.ContainsKey(rptName))
            {
                CrystalReportViewer1.ReportSource = null;
                return;
            }

            var file = Data.Reports[rptName];

            if ((file ?? "") == "")
            {
                CrystalReportViewer1.ReportSource = null;
                return;
            }

            CrystalReportViewer1.ReportSource = file;
        }
        catch(Exception ex)
        {
            MessagesTextBox.Text = ex.Message;
            CrystalReportViewer1.ReportSource = null;
        }
    }

您会注意到我添加了一个文本框来跟踪此过程中发生的情况。同样,在开发过程中,一切都按预期进行但是在生产中,当选择不同的下拉列值时,MessageTextBox根本不会更新。据我所知,没有错误,它只是没有回发,但我无法弄清楚为什么不是因为autopostback设置为true。

0 个答案:

没有答案