Problem with checkboxes in visual web developer express 2008


Short description: When I choose drop-down-list or checkbox-list from the toolbox in Visual web developer express 2008, they both contain a smart tag so I can choose and configure data soure. If I choose checkbox, there is no smart tag.

My question, how do I tell the checkbox where to pick its values from the database.
For mor details. See attached file.

Best regards

Who is Participating?
Anurag ThakurTechnical ManagerCommented:
so far, when ever i have worked with check box list i have always done more than one check box selection with the data getting populated from the database
in your case, use check box list bind it to the database

there are 2 ways of achieving the target
option 1
Have a button on the page and when the button is clicked loop through the check box list, get the selected values and then show the records

option 2
create an event on the check box changed event and the handle the selection accordingly
Anurag ThakurTechnical ManagerCommented:
use check box list if you want to use data source
check box is just single entity thats why smart tag is not applicable there
marcguAuthor Commented:
I know (I even wrote that in my attachted document)  but with check box list there is no way to display multiple choices if I have understood it correctly.

For instance if the user selects both Argentina and Denmark, with checkbox list, only rows matching Argentina will be displayed.

Could you please give a hint on where to read more about the possiblity to use checkboxes to pull data data from a database with visual web developer.

I would be more than grateful.
marcguAuthor Commented:
Thanks a lot. Please take a look at the attached code in this comment. I am not sure where to place the loop. In the default.aspx file or in the default.aspx.vb file? Could some one give a tip on a sample loop that would fit into my code where I just have to change the ID of the checkboxlist and the selectommand?

%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
            SelectCommand="SELECT * FROM [Employees] where EmployeeID=@EmployeeID">
                <asp:ControlParameter ControlID="CheckBoxList1" Name="EmployeeID" 
                    PropertyName="SelectedValue" />
        <asp:CheckBoxList ID="CheckBoxList1" runat="server" 
            DataSourceID="SqlDataSource2" DataTextField="EmployeeID" 
            DataValueField="EmployeeID" RepeatColumns="4">
        <asp:Button ID="Button1" runat="server" Text="Button" />
        <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
            AutoGenerateColumns="False" CellPadding="4" DataKeyNames="EmployeeID" 
            DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None">
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID" 
                    InsertVisible="False" ReadOnly="True" SortExpression="EmployeeID" />
                <asp:BoundField DataField="LastName" HeaderText="LastName" 
                    SortExpression="LastName" />
                <asp:BoundField DataField="FirstName" HeaderText="FirstName" 
                    SortExpression="FirstName" />
                <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                <asp:BoundField DataField="TitleOfCourtesy" HeaderText="TitleOfCourtesy" 
                    SortExpression="TitleOfCourtesy" />
                <asp:BoundField DataField="BirthDate" HeaderText="BirthDate" 
                    SortExpression="BirthDate" />
                <asp:BoundField DataField="HireDate" HeaderText="HireDate" 
                    SortExpression="HireDate" />
                <asp:BoundField DataField="Address" HeaderText="Address" 
                    SortExpression="Address" />
                <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
                <asp:BoundField DataField="Region" HeaderText="Region" 
                    SortExpression="Region" />
                <asp:BoundField DataField="PostalCode" HeaderText="PostalCode" 
                    SortExpression="PostalCode" />
                <asp:BoundField DataField="Country" HeaderText="Country" 
                    SortExpression="Country" />
                <asp:BoundField DataField="HomePhone" HeaderText="HomePhone" 
                    SortExpression="HomePhone" />
                <asp:BoundField DataField="Extension" HeaderText="Extension" 
                    SortExpression="Extension" />
                <asp:BoundField DataField="Notes" HeaderText="Notes" SortExpression="Notes" />
                <asp:BoundField DataField="ReportsTo" HeaderText="ReportsTo" 
                    SortExpression="ReportsTo" />
                <asp:BoundField DataField="PhotoPath" HeaderText="PhotoPath" 
                    SortExpression="PhotoPath" />
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#999999" />
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
        SelectCommand="SELECT DISTINCT [EmployeeID] FROM [Employees]">

Open in new window

The default.aspx.vb -file

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub SqlDataSource1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles SqlDataSource1.Load

    End Sub

    Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting

    End Sub
End Class

Open in new window

marcguAuthor Commented:
Thanks for the information and hint where to search. I found a detailed solution in question with ID: 26853668.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.