Same exact stuff again and again (sigh)…You
FindControl
returned
null
as a control was not found. Exception is thrown at the attempt to read the property
Text
on null object.
Now, your approach is very wrong in tree aspects. First, why asking a question like that without trying to run it under Debugger. You should always do that. It would make it all clear.
Do not develop anything before you are comfortable with the Debugger and readily use it on any smallest problem.
Second problem is:
FindControl
is not intended to be used with regular UI applications. You
should not use Name
property at all; this is all just for Designer. Why searching for anything is all your controls are declared in your Form or Window class and accessible via some class members? It makes no sense; and using this method is a major flaw.
Third:
never use immediate constants, especially like "txtquantify" (wannabe Name :-)). You destroy all your maintenance. If you misspell it, a computer would not detect a problem. Besides, what it you need to use it in two or more different places? (It actually happens because it also appears in the auto-generated code.)
Never ever repeat anything. Do I have to explain why? Here:
http://en.wikipedia.org/wiki/Don%27t_repeat_yourself[
^].
—SA