471,337 Members | 992 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

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 5618

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Agi Chen | last post: by
3 posts views Thread by cannontrodder | last post: by
2 posts views Thread by =?Utf-8?B?UGV0ZXI=?= | last post: by
2 posts views Thread by LVP | last post: by
3 posts views Thread by dbuchanan | last post: by

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.