[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 340
  • Last Modified:

Problem with checkboxes in visual web developer express 2008

Hi!

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



Page-Language.pdf
0
marcgu
Asked:
marcgu
  • 3
  • 2
1 Solution
 
Anurag ThakurCommented:
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
0
 
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.
0
 
Anurag ThakurCommented:
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
0
 
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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
            SelectCommand="SELECT * FROM [Employees] where EmployeeID=@EmployeeID">
            <SelectParameters>
                <asp:ControlParameter ControlID="CheckBoxList1" Name="EmployeeID" 
                    PropertyName="SelectedValue" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:CheckBoxList ID="CheckBoxList1" runat="server" 
            DataSourceID="SqlDataSource2" DataTextField="EmployeeID" 
            DataValueField="EmployeeID" RepeatColumns="4">
        </asp:CheckBoxList>
        <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" />
            <Columns>
                <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" />
            </Columns>
            <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:GridView>
    
    </div>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
        SelectCommand="SELECT DISTINCT [EmployeeID] FROM [Employees]">
    </asp:SqlDataSource>
    </form>
</body>
</html>

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




How-the-page-looks-right-now-aft.pdf
0
 
marcguAuthor Commented:
Thanks for the information and hint where to search. I found a detailed solution in question with ID: 26853668.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now