I am trying to find a way to access the multiple values of a CheckBoxList control.
Here is my code so far:
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="True">
<asp:ListItem Value="02">Office 02</asp:ListItem>
<asp:ListItem Value="12">Office 12</asp:ListItem>
</asp:CheckBoxList></div>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1"
DataTextField="Name" DataValueField="Zone">
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ArchiveConnectionString %>"
SelectCommand="SELECT * FROM [CheckBoxTest] WHERE (([Zone] = @Zone))">
<SelectParameters>
<asp:ControlParameter ControlID="CheckBoxList1" Name="Zone" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</form>
</body>
</html>
I cannot find a way to access all the asp:listitems and do something like a SQL "in" statement. Second, I am not sure if it is even checking if the checkbox is checked.
Thanks
Extended