I want to write a condtional statement that only adds a <br /> after a DataList label if the label contains any data. I have done this in a FormView as follows:
<asp:Label ID="address2" runat="server" Text='<%# Bind("address2") %>' Visible='<%# IIF(CONVERT.ToString(Eval("address2"))="", false, true) %>' />
If FormView1.FindControl("address2").Visible = True Then
I do not know how to write the conditional statement for a DataList though.
If DataList1.FindControl("address2").Visible = True Then
returns an error:
Object reference not set to an instance of an object.
This makes sense as there are multiple rows in a DataList whereas there is only ever one in a FormView.