Reputation: 2295
I am trying to check if a value from database table is equal to Char, in the view I tried
the following:
<% if (Model.MethodOfPayment.ToString().Equals("W") == true)
{
%>
Wire
<%} %>
<%else
{ %>
<% if (Model.MethodOfPayment.ToString().Equals("C") == true)
{
%>
Cheque
<%} %>
<%} %>
Did not work! In the controller to send the output to PDF Form: I tried the following:
string MyString = order.MethodOfPayment.ToString();
if (MyString == "W")
{
pdfFormFields.SetField("MethodOfPayment", "W");
}
else
{
if (MyString == "W")
{
pdfFormFields.SetField("MethodOfPayment", "C");
}
}
Did not work either. Thanks in advance.
Upvotes: 0
Views: 152
Reputation: 1039110
How about:
if (Model.MethodOfPayment == 'W')
If this doesn't work it simply means that the MethodOfPayment
property doesn't equal to the W
character. Try debugging your code to see exactly to which value it equals.
Upvotes: 1