I ran into a problem when I try to show values ββto the user, iterating the object and using HtmlHelpers. Currently, one column will carry the data type of the elements that I am writing to the screen, and they are string values. I ran into a problem when I try to display the value "Boolean", which is a data type string using the DisplayFor method. I get a FormatException: "String was not recognized as a valid boolean." I tried using it as a string in several ways, but no luck. If I change the line from "Boolean" to anything else, it works fine. Any suggestions?
<%foreach (var matrixColumnView in Model.MatrixColumns) {%> <tr id="<%="ColRow_" + matrixColumnView.Key %>" class="columnRow"> <td class="ui-helper-hidden"> <%=Html.HiddenFor(x => x.MatrixColumns[matrixColumnView.Key].EntityId)%> </td> <td> <%=Html.HiddenFor(x => x.MatrixColumns[matrixColumnView.Key].Sequence)%> <%=Html.DisplayFor(x => x.MatrixColumns[matrixColumnView.Key].Sequence, matrixColumnView.Value.Sequence.ToString())%> </td> <td> <%=Html.HiddenFor(x => x.MatrixColumns[matrixColumnView.Key].Name)%> <%=Html.DisplayFor(x => x.MatrixColumns[matrixColumnView.Key].Name, matrixColumnView.Value.Name)%> </td> <td> <%=Html.HiddenFor(x => x.MatrixColumns[matrixColumnView.Key].DataTypeName) %> <%=Html.DisplayFor(x => x.MatrixColumns[matrixColumnView.Key].DataTypeName, (string)matrixColumnView.Value.DataTypeName) %> </td> </tr> <%} %>
source share