tags:

views:

152

answers:

1

I use the RepeatColumns of an ASP CheckBoxList to create three columns in a list of genres. This usually works OK but occasionally when the page loads the columns collapse as indicated on this image. This seems to happen randomly and across all browsers. I do use OutputCache.

Has anyone noticed this behavior before?

This is a snippet of the code:

<table width="100%"><tr><td width="66%" style="padding-left:4px">Genres:</br>

    <asp:CheckBoxList RepeatColumns="3" CssClass="chkChoice" ID="CheckBoxList_Genres" runat="server">
        <asp:ListItem Selected="True">Action</asp:ListItem>
        <asp:ListItem Selected="True">Comedy</asp:ListItem>
        <asp:ListItem Selected="True">Classics</asp:ListItem>
        <asp:ListItem Selected="True">Documentary</asp:ListItem>
        <asp:ListItem Selected="True">Drama</asp:ListItem>
        <asp:ListItem Selected="True">Fantasy</asp:ListItem>
        <asp:ListItem Selected="True">Foreign</asp:ListItem>
        <asp:ListItem Selected="True">Independent</asp:ListItem>
        <asp:ListItem Selected="True">Kids</asp:ListItem>
    </asp:CheckBoxList>

In response to the comment, this is the rendered html:

    <span id="ctl00_ContentPlaceHolder1_CheckBoxList_Genres" class="chkChoice"><input id="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_0" type="checkbox" name="ctl00$ContentPlaceHolder1$CheckBoxList_Genres$0" checked="checked" /><label for="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_0">Action</label><input id="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_3" type="checkbox" name="ctl00$ContentPlaceHolder1$CheckBoxList_Genres$3" checked="checked" /><label for="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_3">Documentary</label><input id="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_6" type="checkbox" name="ctl00$ContentPlaceHolder1$CheckBoxList_Genres$6" checked="checked" /><label for="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_6">Foreign</label><br /><input id="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_1" type="checkbox" name="ctl00$ContentPlaceHolder1$CheckBoxList_Genres$1" checked="checked" /><label for="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_1">Comedy</label><input id="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_4" type="checkbox" name="ctl00$ContentPlaceHolder1$CheckBoxList_Genres$4" checked="checked" /><label for="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_4">Drama</label><input id="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_7" type="checkbox" name="ctl00$ContentPlaceHolder1$CheckBoxList_Genres$7" checked="checked" /><label for="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_7">Independent</label><br /><input id="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_2" type="checkbox" name="ctl00$ContentPlaceHolder1$CheckBoxList_Genres$2" checked="checked" /><label for="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_2">Classics</label><input id="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_5" type="checkbox" name="ctl00$ContentPlaceHolder1$CheckBoxList_Genres$5" checked="checked" /><label for="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_5">Fantasy</label><input id="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_8" type="checkbox" name="ctl00$ContentPlaceHolder1$CheckBoxList_Genres$8" checked="checked" /><label for="ctl00_ContentPlaceHolder1_CheckBoxList_Genres_8">Kids</label></span>
A: 

If you do not mind tabulating the checkboxlist, add RepeatLayout="Table".

E.g.

<asp:CheckBoxList RepeatColumns="3" CssClass="chkChoice" 
  ID="CheckBoxList_Genres" runat="server" 
  RepeatLayout="Table" >....
o.k.w
RepeatLayout="Table" is the default.
Phaedrus
I'm afraid this doesn't seem to have helped. As I noted in the comment above, sometimes the <table...> is rendered and it displays correctly; sometimes it is not and it does not.
alpheus
@Phaedrus: I thought so too, really puzzled by the inconsistent rendering.
o.k.w
@alpheus: Do you have any codes in the code-behind that involves the CheckBoxList other than reading the data from it?
o.k.w
I read the checked items and I also sometimes set items to be checked like this: CheckBoxList_Sources.Items.FindByValue("1").Selected = true;
alpheus