473,795 Members | 2,512 Online
Bytes | Software Development & Data Engineering Community
+ 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:CheckBoxLi st OnSelectedIndex Changed="ItemsI ndexChanged
ID="CheckBoxLis tItems" RepeatColumns=" 2"
RepeatDirection ="Vertical"
RepeatLayout=Ta ble TextAlign="Righ t" Runat="server" >
<asp:ListItem>I tem1</asp:ListItem>
<asp:ListItem>I tem2</asp:ListItem>
</asp:CheckBoxLis t>

GridView
--------
<asp:GridView ID="GridView1" Runat="server"
DataSourceID="S qlDataSourceIte ms"
AutoGenerateCol umns="False" AllowSorting="T rue"
AllowPaging="Tr ue">
<Columns>
<asp:BoundFie ld HeaderText="Ite m1" DataField="Item 1"
SortExpression= "Item1">
</asp:BoundField>
<asp:BoundFie ld HeaderText="Ite m2" DataField="Item 2"
SortExpression= "Item2">
</asp:BoundField>
</Columns>
</asp:GridView>

SqlDataSource
-------------
<asp:SqlDataSou rce ID="SqlDataSour ceTssdSecFillin g" Runat="server"
SelectCommand=" SELECT * FROM [MyTable]
WHERE (([Item1] = @Item1) AND ([Item1] = @Item2))"
ConnectionStrin g="<%$ ConnectionStrin gs:AppConnectio nItems %>"
OnSelecting="Sq lDataSourceItem s_Selecting">
<SelectParamete rs>
<asp:ControlPar ameter Name="Item1"
ControlID="Chec kBoxListItems" Type="Boolean"
PropertyName="? ?????">
</asp:ControlPara meter>
<asp:ControlPar ameter Name="Item2"
ControlID="Chec kBoxListItems" Type="Boolean"
PropertyName="? ?????">
</asp:ControlPara meter>
</SelectParameter s>
</asp:SqlDataSour ce>

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

Regards,
Rob

Jul 21 '05 #1
0 5816

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

Similar topics

0
1499
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 SQL DDL like follows: create table interest ( intId int, intName varchar(20)) go Insert into interest values ( 1, 'Music') Insert into interest values ( 2, 'Jogging') Insert into interest values ( 3, 'Fishing')
0
542
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. 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: ...
3
3183
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 I would like to show a checkboxlist within my formview to represent them. I just have no idea how to bind this collection to a list within the formview? Has anyone got any ideas on this? I don't need the full code, just a pointer in the right...
14
14659
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 so I get the ObjectDataSource. No problem ..... ObjectDataSource src = .... //is ok i have it
0
2745
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 multiple categores (check boxes) and view only the results in those categories in a gridView control. My goal is to do so for movies, so an example would be if the user checks comedy and childrens then they would only get childrens comedies and the...
2
6328
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 the email address has not been filled in because I don’t know how to pass the email variable into the mailto command. <asp:HyperLink runat="server"> <A href="mailto:">
2
1993
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 saved somehow because later on, the selected option will be compared with values from another table. this is possible right? thanks
2
1348
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 loop through it. and get the extra columns passed in the sqldatasource01 I don't want to loop through the CheckBoxList because it does not have all the extra columns.
3
2789
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 properly inform the user of the fact. How is ths done? Thank you, Doug
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10438
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10164
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9042
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7540
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4113
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 we have to send another system
2
3727
muto222
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.