C# .NET - Counting listItems in Checkboxlist in pageload not working

Asked By Pranay on 22-Mar-13 11:17 AM

I have label which displays a message depending on if the checkboxlist has items or not. Now the problem is, the code takes into account the previous pageload and not the current one.
What I'm trying to figure out is, if the control is rendering listItems on the page there should be way to catch it in pageload. I've a sqldatasource attached to this checkboxlist. Any suggestions what I'm missing or doing wrong?

if
(CheckBoxList1.Items.Count == 0)


{

Label1.Visible =


true;


Label1.Text =


"No files in this folder.";


}



else


Label1.Visible =


false;