asp.net checkboxlist control,asp.net checkboxlist scrollbar
Asp.net checkBoxList Control is used to select multiple listitems in CheckBoxList.
<asp:CheckBoxList ID=”CheckBoxList1″ runat=”server”>
<asp:ListItem>Apples</asp:ListItem>
<asp:ListItem>Grapes</asp:ListItem>
<asp:ListItem>Bananas</asp:ListItem>
<asp:ListItem>Mangos</asp:ListItem>
<asp:ListItem>Oranges</asp:ListItem>
<asp:ListItem>Cocoa</asp:ListItem>
<asp:ListItem>CustardApple</asp:ListItem>
<asp:ListItem>Breadfruit</asp:ListItem>
</asp:CheckBoxList>
Properties of CheckBoxList
RepeatColumns: The number of columns used to layout the items
* By default CheckBoxList contain one column
Ex: RepeatColumns =2 then it shows 2 columns
RepeatDirection: The direction in which items are laid out
RepeatDirection= horizontal/vertical
cellpadding: The padding between each item.
cellspacing: The spacing between each item.
Items: adding collection of items in the list.
Dynamically add checkBoxList items at runtime
CheckBoxList1.Items.Add(”Games”);
CheckBoxList1.Items.Add(”Movies”);
…..
…..
Asp.net CheckBoxList Scrollbar
step1: Drag Panel control and checkBoxList
change Panel control properties
ScrollBars=”Vertical”
Width=”250px”
Height=”80px”
Note: Width and height are main important to make scrollbars in panel
Step2: insert checkBoxlist control inside panel control
Sample Code:
<asp:Panel ID=”Panel1” runat=”server” BorderColor=”#CACACA” BorderStyle=”Solid”
BorderWidth=”1px” Height=”80px” ScrollBars=”Vertical” Width=”250px”>
<asp:CheckBoxList ID=”CheckBoxList1″ runat=”server” RepeatColumns=”2″>
<asp:ListItem>Apples</asp:ListItem>
<asp:ListItem>Grapes</asp:ListItem>
<asp:ListItem>Bananas</asp:ListItem>
<asp:ListItem>Mangos</asp:ListItem>
<asp:ListItem>Oranges</asp:ListItem>
<asp:ListItem>Oranges</asp:ListItem>
<asp:ListItem>Cocoa</asp:ListItem>
<asp:ListItem>CustardApple</asp:ListItem>
<asp:ListItem>Breadfruit</asp:ListItem>
</asp:CheckBoxList>
</asp:Panel>
Happy coding…
