Reputation: 183
I have a checkbox list that I am binding it with the database. I want only the checkbox part to be visible, i don't want the items associated to be visbible so for e.g if I have three items in my checkbox list, i just want three text boxes visible and text part to be hidden.
Below is my code
checkboxlist1.DataSource = RadListBox_selectedAssistAgency.Items;
checkboxlist1.DataBind();
Please let me know how can I acheive this.
Upvotes: 1
Views: 2645
Reputation: 46551
Have you assigned a DataTextField
property to your CheckboxList? Leaving that empty might help you.
Upvotes: 1
Reputation: 11945
If you just want to hide the text, a possible solution would be to hide the labels with css:
Css:
.noText label
{
display: none;
}
And in code behind, set the css class:
checkboxlist1.CssClass = "noText";
checkboxlist1.DataSource = RadListBox_selectedAssistAgency.Items;
checkboxlist1.DataBind();
Or set the css class in the html-file:
<asp:CheckBoxList ID="checkboxlist1" runat="server" CssClass="noText">
Another possible solution is to remove the text from the items:
checkboxlist1.DataSource = RadListBox_selectedAssistAgency.Items;
checkboxlist1.DataBind();
foreach (ListItem item in checkboxlist1.Items)
{
item.Text = ""; // Set text to empty.
}
Upvotes: 0