I am writing this post to help people like me who are new to nunit. Bascially it’s easy to setup but some time it can be really hard for some people.

0

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