Directly reading a bound field at runtime in ActiveReports

117 Views Asked by At

I'm trying to conditionally change which DataField a Textbox is using, based on whether the original DataField is empty. **So the logic I want is "if X Datafield is Empty, change it to DataField Y". **

I can alter the DataField at runtime in the ReportStart method, but I can't achieve the conditional behavior as the actual text is not populated yet.

I've tried using a C# expression in the datafield, and also restarting the report if the original DataField is empty, but these haven't worked. **If I can somehow read the bound field directly, or cause manually cause the textbox to draw on the new field when changed, that would work. **

One way that I don't want to use as it would require a lot more manual work is adding extra textboxes that draw on the other field, and either toggling their visibility or using them to read the field from.

1

There are 1 best solutions below

0
JosefThorne On

I figured out how to do this on my own.

XmlDocument quoteXml = (rpt.DataSource as XMLDataSource).Document;
if (quoteXml.SelectSingleNode("[Your XPath here]").InnerText = "") {
  this.MyExampleControl.Datafield = "foo/bar"
}