简体   繁体   中英

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. 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

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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