Hardik Patel

Hardik Patel

  • NA
  • 378
  • 470.4k

how to replace text when binding from database?

Jul 24 2013 12:20 AM
i have one table with column name status.

i want to replace text when i am binding gridview i want to replace True = Yes / False = No


   IN Database   IN Gridview
       Status   status
TRUE   Yes
FALSE   NO
TRUE   Yes


Answers (1)

0
Sanjeeb Lenka

Sanjeeb Lenka

  • 0
  • 15.3k
  • 2.4m
Jul 24 2013 12:28 AM
try like this:

 
<asp:GridView ID="gvArea" runat="server" Width="100%" AutoGenerateColumns="False"
  EmptyDataText="No Records Found">
  <Columns>
  <asp:TemplateField HeaderText="Status">
  <ItemTemplate>
  <asp:Label ID="lblStatus" runat="server" Text='<%# (bool)Eval("Status")?"Yes":"No"%>'></asp:Label>
  </ItemTemplate>
  <HeaderStyle Width="60px" />
  </asp:TemplateField>
  </Columns>
  </asp:GridView>