Monday, 1 October 2012

GridView: How to Efficiently replacing True, False with Yes, No

1. In the GridView add a column->BoundField->DataBound: type the field name to be bound
2. Now convert the BoundField in Step 1 to TemplateField
3. Convert as follows in the :
<asp:templatefield>
        <itemtemplate>
                <%# Convert.ToBoolean(Eval("MyBitField")) ? "Yes" : "No" %>
        </itemtemplate>
        <ItemTemplate>
              <asp:Label ID="Label1" runat="server" Text='<%# Convert.ToBoolean(Eval                         ("Monday"))?"Yes":""%>'></asp:Label>
        </ItemTemplate>
</asp:templatefield>

No comments:

Post a Comment