how to select all items at a time in CheckBoxList

Jayakumars
Posted by Jayakumars under ASP.NET AJAX category on | Points: 40 | Views : 1024
Hi

how to select all items at a time in CheckBoxList

Client Side

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:CheckBoxList ID="chk1" runat ="server" >
<asp:ListItem Text ="Jesus"></asp:ListItem>
<asp:ListItem Text ="Bible"></asp:ListItem>
</asp:CheckBoxList>

<asp:LinkButton ID="lnk1" runat ="server" Text ="Click" onclick="lnk1_Click">
</asp:LinkButton>

</form>
</body>
</html>


Server Side Code

protected void lnk1_Click(object sender, EventArgs e)
{
for(int i=0;i<=chk1.Items.Count-1;i++)
{
chk1.Items[i].Selected=true;
}
}

Comments or Responses

Login to post response