2

Firstly, here is my aspx:

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="EntityDataSourceTeklifler">
  <ItemTemplate>
    <div class="panel panel-primary">
       <div class="panel-body">
          <strong>Teklif No.</strong>&nbsp;<%#Eval("TeklifId") %><br />
          <strong>Teklif Tarihi:</strong>&nbsp;<%#Eval("TeklifTarih") %><br />
          <strong>Teklifi Hazırlayan:</strong>&nbsp;<%#Eval("Name") %>&nbsp;<%#Eval("Surname") %><br />
          <strong>Firma Adı:</strong>&nbsp;<%#Eval("FirmaAdi") %><br />
          <strong>Ürünler:</strong><br />
          <%#Eval("TeklifSiparis") %>
          <strong>Genel Toplam:</strong>&nbsp;<%#Eval("TeklifTutar") %>$<br />
          <strong>Not:</strong><br />
          <%#Eval("TeklifNot") %><br />
          <strong>Teklif Durumu:</strong>&nbsp;<%# CheckIfApproved(Eval("Approved")) %>
           </div>
             </div>
               </ItemTemplate>
                </asp:Repeater>

As you can see I am trying to call a method in the last item of the repeater. Here is my code-behind method:

protected string CheckIfApproved(bool isApproved) 
    {
        string result;
        if (isApproved)
        {
            result = "Satışa Dönmüştür";
        }
        else
        {
            result = "Satışa Dönmemiştir";
        }
            return result;
    }

When I run the code I get an error like 'Compile Error' with no detailed explanation in the method calling eval line. What am I doing wrong ?

1
  • 1
    You're passing in a string as param to your method when it's expecting a bool value Commented Dec 16, 2015 at 9:06

2 Answers 2

1
<%# CheckIfApproved(Convert.ToBoolean(Eval("Approved"))) %>

Modify code as above:

Sign up to request clarification or add additional context in comments.

Comments

0

Try this:

protected string CheckIfApproved(object isApproved) 
    {
        string result;
        if (bool.Parse(isApproved))
        {
            result = "Satışa Dönmüştür";
        }
        else
        {
            result = "Satışa Dönmemiştir";
        }
            return result;
    }

It should be fine!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.