Replace 1's and 0's in a gridview column with Yes's and No's


Is it possible to change the display of a column in a gridview to show a Yes for all 1's and a No for 0's that display in a particular column of a gridview bound to a database?  If so, can someone share the way with me?  I am using ASP.NET 2.0 with VB Code Behind.
 Thanks
0
defyant_2004
1/17/2007 7:47:29 PM
📁 asp.net.presentation-controls
📃 72751 articles.
⭐ 3 followers.

💬 3 Replies
👁️‍🗨️ 2649 Views


One way you can do is thrrough  CASE in your select statement: 

Select
YesNoColumn= CASE yourColumn
WHEN 1 THEN 'Yes'
WHEN
0 THEN 'No'
ELSE
'' END
FROM Yourtable

Limno

0
limno
1/17/2007 8:25:33 PM

<Columns>
     <asp:TemplateField HeaderText="yourHeader" SortExpression="yourDataField">
            <ItemTemplate>
               <asp:Label ID="Label1" Text='<%# changeText(Eval("yourDataField"),30) %>' runat=server ></asp:Label>
            </ItemTemplate>
         </asp:TemplateField> 
</Columns>
CodeBehind
protected string changeText(object fromDatabase)
{
   string dbValue = fromDatabase.ToString().Trim();
   return(        dbValue == "1" ? "Yes" : "No");
0
g2000
1/17/2007 8:30:33 PM

i hav also used it n i make my app wrokd as i needed...
0
jayesh
10/17/2007 3:06:16 PM
Reply: