473,473 Members | 2,169 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Data Binding: GridView & CheckBoxList & SQL

rob
Here is my scenario:

One of my aspx pages has a CheckBoxList (Item1, Item2) and a GridView.
Then I have a database that has the columns Item1 and Item2 (among
others) with the data type bit. What I am trying to do is to only show
the data sets chosen by the user. So for example if the user checks
Item1 in the CheckBoxList then only the datasets that have Item1 set to
True should be listed in the GridView. Here is what I tried:

Checkboxlist
------------
<asp:CheckBoxList OnSelectedIndexChanged="ItemsIndexChanged
ID="CheckBoxListItems" RepeatColumns="2"
RepeatDirection="Vertical"
RepeatLayout=Table TextAlign="Right" Runat="server" >
<asp:ListItem>Item1</asp:ListItem>
<asp:ListItem>Item2</asp:ListItem>
</asp:CheckBoxList>

GridView
--------
<asp:GridView ID="GridView1" Runat="server"
DataSourceID="SqlDataSourceItems"
AutoGenerateColumns="False" AllowSorting="True"
AllowPaging="True">
<Columns>
<asp:BoundField HeaderText="Item1" DataField="Item1"
SortExpression="Item1">
</asp:BoundField>
<asp:BoundField HeaderText="Item2" DataField="Item2"
SortExpression="Item2">
</asp:BoundField>
</Columns>
</asp:GridView>

SqlDataSource
-------------
<asp:SqlDataSource ID="SqlDataSourceTssdSecFilling" Runat="server"
SelectCommand="SELECT * FROM [MyTable]
WHERE (([Item1] = @Item1) AND ([Item1] = @Item2))"
ConnectionString="<%$ ConnectionStrings:AppConnectionItems %>"
OnSelecting="SqlDataSourceItems_Selecting">
<SelectParameters>
<asp:ControlParameter Name="Item1"
ControlID="CheckBoxListItems" Type="Boolean"
PropertyName="??????">
</asp:ControlParameter>
<asp:ControlParameter Name="Item2"
ControlID="CheckBoxListItems" Type="Boolean"
PropertyName="??????">
</asp:ControlParameter>
</SelectParameters>
</asp:SqlDataSource>

I just can't get this to work no matter what I set for the two
controlParameters in the SqlDataSource. It works just fine for a
TextBox. Any help is appreciated.

Regards,
Rob

Jul 21 '05 #1
0 5784

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Agi Chen | last post by:
Hello, theres, I'm newbie in asp.net. I have problem in CheckBoxList binding to database. Considering my case in a member system, if I have 2 tables one for interest, one for memberInterest the...
0
by: rob | last post by:
Here is my scenario: One of my aspx pages has a CheckBoxList (Item1, Item2) and a GridView. Then I have a database that has the columns Item1 and Item2 (among others) with the data type bit....
3
by: cannontrodder | last post by:
I am displaying names and other details of my users in a Formview control by binding my custom business object to it. My custom object also has a property that is a collection of boolean values and...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
0
by: joebob8000 | last post by:
This seems like a simple task, but my 6 year old roots in classic ASP must be causing me trouble with my current problem. I am looking to provide a search for users in which they can select...
2
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
Hi, I want to create a mailto link from data coming from an SQLDataSource. How do I have to change the following code to get it working? The mailto works, outlook starts with a new message, but...
2
by: mercea | last post by:
hi all, i have a grid view and i have inserted a checboxlist template with 5checkboxes per row into the gridview. i want the user to be able to select an option (A-E) and that selected option be...
2
by: LVP | last post by:
Hi, I have a sqldatasource01 configured properly and can databind it to a CheckBoxList and see data with no problem. How can I get the data programmatically from the sqldatasource01 I need to...
3
by: dbuchanan | last post by:
How, at rundime, do I capture the fact that the parametrized query that fills a CheckBoxList results in an empty set. When the dataset is empty the CheckBoxList does not appear. I would like to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.