Last post Sep 02, 2019 09:00 AM by jiadongm
Aug 30, 2019 06:21 AM|demoninside9|LINK
This question is not about any issue. It is just to know the best approach regarding the solution.
I have a view in my application. There are around 150 controls on the page. See the image below for reference.
Above is the only one segment, there are many below.
When I submit the page it saves all value in database.
Now when I want to open it in edit mode, I need to write for every control if the model property have value then show control other wise don't show control.
// change the property of div from display:none to display:block
By default all controls are display:none;
I just want to know, is there any other (common) approach which works for all control ?
If yes, then please suggest.
Sep 02, 2019 09:00 AM|jiadongm|LINK
You can use Reflection to determine whether to display the property of the model by checking its value like this:
var properties = Model.GetType().GetProperties();
foreach(var p in properties)
if(p.GetValue(Model) != null)
//change the property of div from display:none to display:block