473,785 Members | 2,756 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 5815

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
10319
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...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10087
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
8971
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...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
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
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.