troubleshooting Question

databinding sqldatasource with parameters

Avatar of troosters
troostersFlag for Belgium asked on
.NET ProgrammingC#ASP.NET
3 Comments1 Solution656 ViewsLast Modified:
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" />
...

 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();
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros