Question

I think I may be using the the wrong controls, but currently I have a datalist which shows a name and then has 2 check boxes

<asp:DataList ID="DataList1" runat="server" DataKeyField="AlbumID" >
    <ItemTemplate>
        Name:
        <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("aName") %>' />
        <br />   
        CD:
        <asp:CheckBox ID="OnCD" runat="server" Text='<%# Eval("AlbumID") %>' />
        <br />
        MP3:
        <asp:CheckBox ID="OnMP3" runat="server" Text='<%# Eval("AlbumID") %>' />
        <br />
        <br />
        <br />
    </ItemTemplate>
</asp:DataList>

When a button is pressed I loop through all of the checked 'OnCD' and 'OnMP3' and update the DB, using the check box text (AlbumID) to identify the correct row.

My only real problem is that the text (AlbumID) is showing up as a label. Since I cant find a simple way to hide this I'm now assuming that I'm not using the right control somewhere.

Is there a way of hiding the text, more over should I be using a control other then the DataList or Checkbox?

Was it helpful?

Solution

Add a css class to the checkboxes:

<asp:DataList ID="DataList1" runat="server" DataKeyField="AlbumID" >
    <ItemTemplate>
        Name:
        <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("aName") %>' />
        <br />   
        CD:
        <asp:CheckBox ID="OnCD" CssClass="hidden" runat="server" Text='<%# Eval("AlbumID") %>' />
        <br />
        MP3:
        <asp:CheckBox ID="OnMP3" CssClass="hidden" runat="server" Text='<%# Eval("AlbumID") %>' />
        <br />
        <br />
        <br />
    </ItemTemplate>
</asp:DataList>

And the style:

<style>        
    .hidden label
    {
        display:none;
    }
</style>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top