How to Use Code Behind to display text on Binding
I had to display Yes or No based on databind this is how I did it.
<asp:Label ID=”IsUserActiveCheckBox” Text=’<%# if(Eval(“IsUserActive”),”Yes”,”No”) %>’
runat=”server” />
Also Bind will not work if you are databinding it.
Here is another example where I used code behind.
in Aspx :
<asp:RadioButtonList ID=”rbGLRSearch” runat=”server” RepeatDirection=”Horizontal”
OnSelectedIndexChanged=”EnableCluster” AutoPostBack=”true” SelectedValue=’<%# GetCheckBoxValue(Eval(“GLRSearch”)) %>’>
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
<asp:ListItem>N/A</asp:ListItem>
</asp:RadioButtonList>
in code behind :
Protected Function GetCheckBoxValue(ByVal bool) As String
If bool Is Nothing Then
Return “N/A”
ElseIf bool = True Then
Return “Yes”
ElseIf bool = False Then
Return “No”
End If
Return True
End Function
Related posts:
- How to read HTML file onServer in ASP.Net
- Read all Mail Merge Field in an Collection.
- Read a Web Page and send it as an HTML Email
- Ajax CalanderExtender :Display dates of current (selected) month only

