if (Request.QueryString["UseGroups"] != null)
{
if (Request.QueryString["UseGroups"] == "True")
{
report.IncludeGroupFiltering = true;
}
else
{
report.IncludeGroupFiltering = false;
}
}
else
{
report.IncludeGroupFiltering = false;
}
The problem only occurs when you have many nested in many and so it can become hard to read and you may forget something, but that's readability, there is nothing wrong in the logic for using nested if statements.
getSelection() != null can however often be transformed to reduce the nesting. Consider some kind of if (freqChooser. getSelection() == null) { return ... } or similar possibilities.
Simply a single check:
report.IncludeGroupFiltering = Request.QueryString["UseGroups"] == "True";
There's no need to evaluate Request.QueryString["UseGroups"]
twice - it can only be equal to "True" if it's non-null, and the comparison will work perfectly well (and return false) if it is null.
Any solutions still doing two operations are over-complicating matters :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With