hncl
hncl

Reputation: 2295

Char equals to String

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

Answers (1)

Darin Dimitrov
Darin Dimitrov

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

Related Questions