简体   繁体   English

Telerik报表:如何处理在报表上生成红色错误框的空日期?

[英]Telerik Reporting: how to handle null dates that generate red error box on the report?

A date field supplies the value for one of the textboxes on the report; 日期字段为报告中的一个文本框提供值; here's how the textbox property page looks: 文本框属性页的外观如下:

         Value       =Fields.eventdate.ToString("D")

When eventdate is null, the report displays an error box in red. eventdate为null时,报告将以红色显示错误框。 What's the proper way to handle null values in this scenario? 在这种情况下,处理空值的正确方法是什么?

I tried using the ternary operator in place of the above, but that causes an error: 我尝试使用三元运算符代替上述方法,但这会导致错误:

         Value       =(Fields.evendate != null) ? : Fields.eventdate.ToString("D") : String.Empty

Is it possible to trap this null in the ItemDataBinding eventhandler associated with the textbox? 是否可以在与文本框关联的ItemDataBinding事件处理程序中捕获此null? It doesn't seem as though the Fields collection is accessible from there: 似乎无法从此处访问Fields集合:

   private void textBox28_ItemDataBinding(object sender, EventArgs e)
    {
          Telerik.Reporting.Processing.TextBox tb = (Telerik.Reporting.Processing.TextBox) sender;
          .
          .
          .
    }

Got it: 得到它了:

private void textBox28_ItemDataBinding(object sender, EventArgs e)
{
  Telerik.Reporting.Processing.ReportItemBase item ;
  item = (Telerik.Reporting.Processing.ReportItemBase)sender;
  System.Data.DataRowView drv = (item.DataObject.RawData as System.Data.DataRowView);

  //now test the drv.Row[ colname ] for DBNull.Value

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM