1

can someone please explain the meaning of the following line

<%#Eval("MType").ToString() == "0" ? "&nbsp;" : "<input type=\"checkbox\"  name=\"cb_Show_" + Eval("MType") + "_" + Eval("ID") + "\" " + ((bool)Eval("IsShow") ? "checked" : "") + " />" %>

All checkboxes are checked based on the above fields. Can someone please tell how eval works

neo
  • 37
  • 9

1 Answers1

0

Eval is "evaluating" those variables to help render the desired content. I think it's usually done inside a databound control. The # sign indicates the databinding.

You also have a ternary operator used here (the ?). It's very powerful and useful to keep code tighter and succinct.

So in the first part if MType is equal to 0 when converted to a string, then it will show a space, otherwise it will show an input box.

The input box has other attribute changes to it based on the Eval()'s as well.

secretwep
  • 706
  • 1
  • 12
  • 28