Re: Oppinion wanted

Tech-Archive recommends: Fix windows errors by optimizing your registry




One more suggestion.
For a long time I did as suggested by Hilton:
Label label = e.Row.FindControl (LABEL_BLOB) as Label;
if (label != null)
label.Text = "Yes";

But recently, I refused that way and now I am writing so:
Label label = e.Row.FindControl (LABEL_BLOB) as Label;
label.Text = "Yes";

I think the first way is meaningful only when the code is written in a
base class. In a situation where there is a certain aspx/ascx file and
the corresponding code the second variant is more preferable.
Why? There are two situations when the label can be equal to null:
1. LABEL_BLOB does not correspond to control id.
2. Incorrect item template in aspx file (missing label)

The end user can not cause such error. Both situations are caused by
errors in the design
and must be corrected at the design stage.

When we write
if (label != null) ...
we just hide a design error while application is executed.

Of course, my assertions may be somewhat debatable :)

Mykola,
http://marss.co.ua

.



Relevant Pages

  • Re: Default use Specific Printer and Label Size
    ... Thanks, however this is a .mde file, so the design view wouldn't be available. ... Dim rpt As Access.Report ... Dim lngNumber As Long ... 'print to the label printer ...
    (comp.databases.ms-access)
  • Re: Sequence numbering labels
    ... I could put this in the label/report design and it would calculate this on ... table field to the query output grid' ...that I did not understand, ... showing in the query output grid already as a natural result of query - - ... and put that count field into the label via label wizard. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Finding records with a form
    ... The search functions start with a label with a yellow background (I could ... Both combo boxes would show both Client and LoanNo in them. ... it's been fun transmitting some of my forms design paradigm. ...
    (microsoft.public.access.formscoding)
  • Re: Naxos is kicking ass, taking names
    ... >> Anyway, regardless of whether one likes the design or not, the label is ... >> once major label crossover krap. ... Schwarz's Diamond with the Seattle SO, are good examples, even going as far ...
    (rec.music.classical.recordings)
  • Re: Naxos is kicking ass, taking names
    ... > Anyway, regardless of whether one likes the design or not, the label is very ... > once major label crossover krap. ... > death for the millionth time by a hyped-up finger wizard. ... Once in a while you see something on Naxos that has appeared previously on ...
    (rec.music.classical.recordings)