I have a repeater on my page, and I need to check in the code-behind to see if any of the Eval("fields") are null. Based on the presence or absence of data in the databound field, I need to turn the literal and it's associated label on the web page to visible = true (if there's data present) or visible=false (if there's no data in that field), so that only the fields with data and their associated headers show on the page.
I don't know if I've just been staring at this for too long or what, but nothing seems to make sense.
I'm using C#, so an example in C# would be appreciated. I've searched the net and found a few VB examples, but they didn't really seem relevant. Some say to check it in the <%# Eval("field") %> area, some say to write a custom function. I'd rather keep it simple and just do this in the code behind if possible (see code example - I know the syntax is not correct, but it's for illustrative purposes).
if (Eval("description") == null)
((Literal)Page.FindControl("litDescription")).Visible = false;
if (Eval("admission") == null)
((Literal)Page.FindControl("litAdmission")).Visible = false;
((Label)Page.FindControl("lbladmissionHdr")).Visible = false;