Method 1:
Select
Case Sex
When ' 1 ' THEN ' male '
When ' 0 ' THEN ' woman '
ELSE ' no man or woman. haha
End as Sex
From TestName
Method 2:
Processing in RowDataBound
if (Index of e.row.cells[column). Text = = "0")
... {
Index of the e.row.cells[column]. text= "Male";
}
Else
... {
Index of the e.row.cells[column]. text= "female";
}
Method 3: Template column (sex = = "1"?) Male ":" female ")
To use a template column:
< Asp:templatecolumn HeaderText = "Gender" >
< ItemTemplate >
< Asp:label runat = "server" Text = ' <%# databinder.eval (Container, ' dataitem.sex '). ToString () = "1"? Male ":" Female "% > ' id=" Label1 ">
</Asp:label >
</ItemTemplate >
</asp:templatecolumn >
Attention:
If the field is bit <%# (bool) Eval ("Sex")? "Male": "Female"%>
If it is char <%# DataBinder.Eval (Container.DataItem, "Sex"). ToString () = = "1"? Male ":" Female "%>
Method 4: Custom Functions
CS Files: Foreground: Protected string showsex (int temp) ... {
if (temp == 1) .. {
return "Male";}
else ... {
return "female";
}
}
< asp:templatefield HeaderText = "gender" >
< ItemTemplate >
< asp:label ID = "F_sex" runat = "server" text = ' <%# showsex (Convert.ToInt32 (Eval ("F _sex ")) % > ' > ' > </asp:label >
</ItemTemplate >
Reproduced from the Banyan tree under the yang too