I am trying to fix this ugly code.
RadGrid gv = (RadGrid) (((Control) e.CommandSource).Parent.Parent.Parent.Parent.Parent);
I often need to find the first grid that is the parent of the parent element ... etc. the object that just raised the event.
The above tends to break when you change the layout and increase or decrease the number of .Parents.
I do not have a control identifier, so I cannot use FindControl ().
Is there a better way to find the first parent grid?
source
share