I am trying to do a simple conditional statement binding in XtraReports. I have my main reports bound to my dataset, my fields (GoalAmount, GoalName, GoalNumber, GoalStart, GoalEnd).

Now GoalNumber or GoalAmount are populated. It's always one or another. So I want to do something like -

Private void Detail_BeforePrint(object sender, PrintEventArgs e) {
   if ([GoalNumber] != null) {
       xrLabelGoal.Text = [GoalNumber].ToString()
   }
   else {
      xrLabelGoal.Text = [GoalAmount].ToString()
   }

   xrCWPerct.Text = Convert.ToString(Convert.ToInt32(xrLabelGoal.Text)/Convert.ToInt32(xrLabelCurrentValue.Text);
}

Thanks for the help.

有帮助吗?

解决方案

I found the answer -

xrLabelGoal.Text =  ((DataRowView)GetCurrentRow()).Row["goalnumber"].ToString();

Turns out I was missing the System.Data which allowed me to use the DataRowView. This fixed it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top