Can I convert a boolean to Yes/No in a ASP.NET GridView

前端 未结 9 1276
孤街浪徒
孤街浪徒 2020-12-22 17:17

I have a ASP.NET GridView with a column mapped to a boolean. I want do display \"Yes\"/\"No\" instead of \"True\"/\"False\". Well actually I want \"Ja\"/\"Nej\"

9条回答
  •  情话喂你
    2020-12-22 17:41

    Add a method to your page class like this:

    public string YesNo(bool active) 
    {
      return active ? "Yes" : "No";
    }
    

    And then in your TemplateField you Bind using this method:

    <%# YesNo(Active) %>
    

提交回复
热议问题