Link to home
Start Free TrialLog in
Avatar of troosters
troostersFlag for Belgium

asked on

databinding sqldatasource with parameters

I have a list of checkboxes and a button and listview and a detailsview.
The code below works, BUT with this code it is either true or false.
But what if I would ALL records containing a TRUE for RegionNorth, and all the others I don't know if they are also true or false ?

<asp:CheckBox ID="Employed" runat="server" Text="Heeft werk" />
        <asp:CheckBox ID="parttime" runat="server" Text="Deeltijds" />
        <asp:CheckBox ID="Fulltime" runat="server" Text="Voltijds" />
        <asp:CheckBox ID="RegionNorth" runat="server" Text="Noord" />
        <asp:CheckBox ID="RegionEast" runat="server" Text="Oost" />

 <asp:SqlDataSource ID="SqlDataSourceEmpList" runat="server" ConnectionString="<%$ ConnectionStrings:kopaConnectionString %>" 
           
             SelectCommand="SELECT * FROM [Cursisten] WHERE ([Employed]=@Employed) AND ([Deeltijds]=@Deeltijds) AND ([Voltijds]=@Voltijds) AND ([RegioNoord]=@RegioNoord) AND ([RegioOost]=@RegioOost) AND ([RegioMidden]=@RegioMidden) AND ([RegioZuid]=@RegioZuid) AND ([RegioWest]=@RegioWest) AND ([JobCoaching]=@JobCoaching) AND ([LanguageCoaching]=@LanguageCoaching) AND ([AfterCare]=@AfterCare)   ORDER BY [Name]" >
             <SelectParameters>
                 <asp:Parameter Name="Employed" Type="Boolean" />
                 <asp:Parameter Name="Deeltijds" Type="Boolean" />
                 <asp:Parameter Name="Voltijds" Type="Boolean" />
...

Open in new window


 SqlDataSourceEmpList.SelectParameters["Employed"].DefaultValue = Employed.Checked.ToString();
            SqlDataSourceEmpList.SelectParameters["Deeltijds"].DefaultValue = Deeltijds.Checked.ToString();
            SqlDataSourceEmpList.SelectParameters["Voltijds"].DefaultValue = Voltijds.Checked.ToString();
            SqlDataSourceEmpList.SelectParameters["RegioNoord"].DefaultValue = RegioNoord.Checked.ToString();
 lvwEmployees.DataBind();

Open in new window

Avatar of Bob Learned
Bob Learned
Flag of United States of America image

I don't understand what you are looking for...
Avatar of troosters

ASKER

Well with this I have 10 checkboxes which explicitly are true or false to use in the query. But what if the user wants all results of only one checkbox ?
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial