Avatar of troosters
Flag 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]" >
                 <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();

Open in new window

C#ASP.NET.NET Programming

Avatar of undefined
Last Comment
Bob Learned

8/22/2022 - Mon
Bob Learned

I don't understand what you are looking for...

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 ?
Bob Learned

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes