Re: Oppinion wanted
- From: marss <marss.ua@xxxxxxxxx>
- Date: Fri, 31 Aug 2007 05:04:15 -0700
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
.
- Follow-Ups:
- Re: Oppinion wanted
- From: Hilton
- Re: Oppinion wanted
- References:
- Re: Oppinion wanted
- From: Hilton
- Re: Oppinion wanted
- Prev by Date: Re: TCP connection to MAC address
- Next by Date: Re: Regex question
- Previous by thread: Re: Oppinion wanted
- Next by thread: Re: Oppinion wanted
- Index(es):
Relevant Pages
|