In reply to sharat:
@sharat, Code is too big, the behavior is same as I have posted in the question code.
In your initial solution
Actually if I pass parameter instead of input value “sel” I am not getting any error. and compilation is successful.
Also whatever code I have given in question, for that compilation is successful, but problem is only else part of that code is working .