开发者

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

开发者 https://www.devze.com 2023-04-04 23:43 出处:网络
A date field supplies the value for one of the textboxes on the report; here\'s how the textbox property page l开发者_高级运维ooks:

A date field supplies the value for one of the textboxes on the report; here's how the textbox property page l开发者_高级运维ooks:

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

When eventdate is null, the report displays an error box in red. 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? It doesn't seem as though the Fields collection is accessible from there:

   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

}
0

精彩评论

暂无评论...
验证码 换一张
取 消