Link to home
Start Free TrialLog in
Avatar of BOEING39
BOEING39

asked on

GRIDVIEW FILTER LISTBOX

I have the attached gridview that has three controls for fltering.   Two dropdowns and a Multiselect Listbox.   The dropdown controls:  DropSta, DropShift work fine.    The Listbox
ListJob filters only one selection.   Need help on code for the list box select statement.
<!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">
<META HTTP-EQUIV="refresh" CONTENT="350">  
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Administrative Page</title>
<style type="text/css">
.style1 {
	border-color: #c0c0c0;
	border-width: 0;
	background-color: #ffffff;
}
.style2 {
	font-size: large;
	text-align: center;
	color: #000080;
}
.style10 {
	text-align: left;
}
.style12 {
	text-align: center;
}
.style15 {
	background-color: #ffffff;
	border-left-color: #c0c0c0;
	border-left-width: 0px;
	border-right-color: #c0c0c0;
	border-right-width: 0px;
	border-top-color: #c0c0c0;
	border-top-width: 0px;
	border-bottom-color: #c0c0c0;
	border-bottom-width: 0;
}
.style16 {
	border-top-style: solid;
	border-top-width: 1px;
}
.style19 {
	font-size: large;
	text-align: center;
	color: #000080;
	font-family: Arial;
}
.style20 {
	font-size: large;
	text-align: left;
	color: #000080;
}
.style21 {
	font-size: small;
	text-align: left;
	color: #000080;
	font-family: Arial;
}
</style>
</head>

<body>

<form id="form1" runat="server">
	<table style="width: 1100px" cellpadding="0" cellspacing="0" class="style1" align="center">
		<tr>
			<td class="style19"><strong>LAS Personnel Administrative Page&nbsp; </strong></td>
		</tr>
		<tr>
			<td class="style2" style="height: 20px"></td>
		</tr>
		<tr>
			<td class="style21">
		&nbsp;Select Station:&nbsp;&nbsp;
		<asp:DropDownList runat="server" id="DropSta" Width="100px" Height="22px" DataValueField="Station" DataTextField="Station" AppendDataBoundItems="True" DataSourceID="AccessDataSource2">
		<asp:ListItem Value=" "></asp:ListItem>
		</asp:DropDownList>
		
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Filter By Shift:&nbsp;&nbsp;
		<asp:DropDownList runat="server" id="DropShift" Width="135px" Height="22px" DataValueField="Shift" DataTextField="Shift" AppendDataBoundItems="True" DataSourceID="AccessDataSource3">
		<asp:ListItem Value=" "></asp:ListItem>
		</asp:DropDownList>
		
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
		Filter By Function:&nbsp;&nbsp;
		<asp:ListBox runat="server" id="ListJob" SelectionMode="Multiple" DataSourceID="AccessDataSource4" DataTextField="Job" DataValueField="Job">
		</asp:ListBox>
		<asp:AccessDataSource runat="server" ID="AccessDataSource4" DataFile="personnel.mdb" SelectCommand="SELECT DISTINCT [Job] FROM [Results]">
		</asp:AccessDataSource>
		<asp:AccessDataSource runat="server" ID="AccessDataSource3" DataFile="personnel.mdb" SelectCommand="SELECT DISTINCT [Shift] FROM [Results]">
		</asp:AccessDataSource>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
		<br />
		<br />
&nbsp;<asp:Button runat="server" Text="Submit" id="Button2" /><asp:AccessDataSource runat="server" ID="AccessDataSource2" DataFile="personnel.mdb" SelectCommand="SELECT DISTINCT [Station] FROM [Results]">
		</asp:AccessDataSource>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
		&nbsp;&nbsp;
			
			</td>
		</tr>
		<tr>
			<td class="style20">
		&nbsp;<strong>&nbsp;&nbsp;&nbsp;</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
		&nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp;&nbsp; </td>
		</tr>
	</table>
	<table style="width: 1100px" cellpadding="0" cellspacing="0" class="style1" align="center">
		<tr>
			<td class="style10"><br />
			<div class="style10">
				<asp:GridView runat="server" id="GridView1" AutoGenerateColumns="False" DataKeyNames="ID" AllowPaging="True" AllowSorting="True" ShowFooter="True" GridLines="None" PageSize="70" DataSourceID="AccessDataSource1">
					<RowStyle Font-Names="Arial" Font-Size="8pt" Width="1300px" />
					<Columns>
						<asp:commandfield ShowEditButton="True" ShowSelectButton="True">
						</asp:commandfield>
						<asp:templatefield ShowHeader="False">
							<ItemTemplate>
								<asp:LinkButton ID="LinkButton1" runat="server" ForeColor="Black" CausesValidation="False" CommandName="Delete" OnClientClick="return confirm(&quot;Are you sure you want to delete this entry?&quot;);" Text="Delete" />
							</ItemTemplate>
							<ItemStyle HorizontalAlign="Left" Wrap="False" ForeColor="Black" Width="40px" />
						</asp:templatefield>
						<asp:templatefield HeaderText="Item">
							<ItemTemplate>
								<%# Container.DataItemIndex + 1 %>
							</ItemTemplate>
							<HeaderStyle Font-Underline="True" />
							<ItemStyle HorizontalAlign="Center" Wrap="False" ForeColor="Black" Width="75px" />
						</asp:templatefield>
						<asp:boundfield DataField="Name" HeaderText="Name" SortExpression="Name">
							<ItemStyle HorizontalAlign="Left" Wrap="False" Width="130px" />
						</asp:boundfield>
						<asp:boundfield DataField="Clock" HeaderText="Clock" SortExpression="Clock">
							<HeaderStyle HorizontalAlign="Center" />
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="50px" />
						</asp:boundfield>
						<asp:templatefield HeaderText="Station" SortExpression="Station">
							<EditItemTemplate>
								<asp:DropDownList runat="server" id="StaDrop" Width="85px" Height="22px" DataValueField="Station" DataTextField="Station" DataSourceID="AccessDataSource10" SelectedValue='<%# Bind("Station") %>'>
								</asp:DropDownList>
								<asp:AccessDataSource runat="server" ID="AccessDataSource10" DataFile="personnel.mdb" SelectCommand="SELECT DISTINCT [Station] FROM [Dropdown]">
								</asp:AccessDataSource>
								&nbsp;
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("Station") %>' id="Label1">
								</asp:Label>
							</ItemTemplate>
							<HeaderStyle HorizontalAlign="Center" />
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="70px" />
						</asp:templatefield>
						<asp:templatefield HeaderText="RDO" SortExpression="RDO">
							<EditItemTemplate>
								<asp:DropDownList runat="server" id="RDODrop" DataValueField="RDO" DataTextField="RDO" DataSourceID="AccessDataSource11" SelectedValue='<%# Bind("RDO") %>'>
								</asp:DropDownList>
								&nbsp;
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("RDO") %>' id="Label2">
								</asp:Label>
							</ItemTemplate>
							<HeaderStyle HorizontalAlign="Center" />
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="60px" />
						</asp:templatefield>
						<asp:boundfield DataField="DOB" HeaderText="DOB" SortExpression="DOB">
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="75px" />
						</asp:boundfield>
						<asp:templatefield HeaderText="Job" SortExpression="Job">
							<EditItemTemplate>
								<asp:DropDownList runat="server" id="JobDrop" Width="176px" Height="22px" DataValueField="JOB" DataTextField="JOB" DataSourceID="AccessDataSource19" SelectedValue='<%# Bind("Job") %>'>
								</asp:DropDownList>
								<asp:AccessDataSource runat="server" ID="AccessDataSource19" DataFile="personnel.mdb" SelectCommand="SELECT DISTINCT [JOB] FROM [Dropdown]">
								</asp:AccessDataSource>
								&nbsp;
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("Job") %>' id="Label3">
								</asp:Label>
							</ItemTemplate>
							<HeaderStyle HorizontalAlign="Center" />
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="110px" />
						</asp:templatefield>
						<asp:templatefield HeaderText="Shift" SortExpression="Shift">
							<EditItemTemplate>
								<asp:DropDownList runat="server" id="ShiftDrop" DataValueField="SHIFT" DataTextField="SHIFT" DataSourceID="AccessDataSource13" SelectedValue='<%# Bind("Shift") %>'>
								</asp:DropDownList>
								<asp:AccessDataSource runat="server" ID="AccessDataSource13" DataFile="personnel.mdb" SelectCommand="SELECT DISTINCT [SHIFT] FROM [Dropdown]">
								</asp:AccessDataSource>
								&nbsp;
							</EditItemTemplate>
							<ItemTemplate>
								<asp:Label runat="server" Text='<%# Bind("Shift") %>' id="Label4">
								</asp:Label>
							</ItemTemplate>
							<HeaderStyle HorizontalAlign="Center" />
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="50px" />
						</asp:templatefield>
						<asp:boundfield DataField="PriNo" HeaderText="PriNo" SortExpression="PriNo">
							<HeaderStyle HorizontalAlign="Center" />
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="100px" />
						</asp:boundfield>
						<asp:boundfield DataField="SecNo" HeaderText="SecNo" SortExpression="SecNo">
							<HeaderStyle HorizontalAlign="Center" />
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="100px" />
						</asp:boundfield>
						<asp:boundfield DataField="Seniority" HeaderText="Seniority" SortExpression="Seniority">
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="80px" />
						</asp:boundfield>
						<asp:boundfield DataField="Radio" HeaderText="M-700" SortExpression="Radio">
							<HeaderStyle HorizontalAlign="Center" />
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="75px" />
						</asp:boundfield>
						<asp:boundfield DataField="Locker" HeaderText="A&amp;P#" SortExpression="Locker">
							<ItemStyle HorizontalAlign="Center" Wrap="False" Width="75px" />
						</asp:boundfield>
					</Columns>
					<FooterStyle BackColor="Navy" Font-Names="Arial" Font-Size="Small" />
					<PagerStyle BackColor="Navy" Font-Names="Arial" ForeColor="White" />
					<HeaderStyle BackColor="Navy" Font-Names="Arial" Font-Size="Small" ForeColor="White" />
					<EditRowStyle Width="1000px" />
					<AlternatingRowStyle BackColor="Blue" ForeColor="White" />
				</asp:GridView>
				<asp:AccessDataSource runat="server" ID="AccessDataSource1" DataFile="personnel.mdb" SelectCommand="SELECT [ID], [Name], [Clock], [Station], [RDO], [DOB], [Job], [Shift], [PriNo], [SecNo], [Seniority], [Radio], [Locker] FROM [Results] WHERE ([Station] = ? and [Shift] = ? and [Job] =?)" DeleteCommand="DELETE FROM [Results] WHERE [ID] = ?" InsertCommand="INSERT INTO [Results] ([Name], [Clock], [Station], [RDO], [DOB], [Job], [Shift], [PriNo], [SecNo], [Seniority], [Radio], [Locker]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" UpdateCommand="UPDATE [Results] SET [Name] = ?, [Clock] = ?, [Station] = ?, [RDO] = ?, [DOB] = ?, [Job] = ?, [Shift] = ?, [PriNo] = ?, [SecNo] = ?, [Seniority] = ?, [Radio] = ?, [Locker] = ? WHERE [ID] = ?">
					<SelectParameters>
						<asp:controlparameter ControlID="DropSta" PropertyName="SelectedValue" Name="Station" Type="String" />
						<asp:controlparameter ControlID="DropShift" PropertyName="SelectedValue" Name="Shift" Type="String" />
						<asp:controlparameter ControlID="ListJob" PropertyName="SelectedValue" Name="Job" Type="String" />

					</SelectParameters>
					<DeleteParameters>
						<asp:parameter Name="ID" Type="Int32" />
					</DeleteParameters>
					<UpdateParameters>
						<asp:parameter Name="Name" Type="String" />
						<asp:parameter Name="Clock" Type="String" />
						<asp:parameter Name="Station" Type="String" />
						<asp:parameter Name="RDO" Type="String" />
						<asp:parameter Name="DOB" Type="String" />
						<asp:parameter Name="Job" Type="String" />
						<asp:parameter Name="Shift" Type="String" />
						<asp:parameter Name="PriNo" Type="String" />
						<asp:parameter Name="SecNo" Type="String" />
						<asp:parameter Name="Seniority" Type="String" />
						<asp:parameter Name="Radio" Type="String" />
						<asp:parameter Name="Locker" Type="String" />
						<asp:parameter Name="ID" Type="Int32" />
					</UpdateParameters>
					<InsertParameters>
						<asp:parameter Name="Name" Type="String" />
						<asp:parameter Name="Clock" Type="String" />
						<asp:parameter Name="Station" Type="String" />
						<asp:parameter Name="RDO" Type="String" />
						<asp:parameter Name="DOB" Type="String" />
						<asp:parameter Name="Job" Type="String" />
						<asp:parameter Name="Shift" Type="String" />
						<asp:parameter Name="PriNo" Type="String" />
						<asp:parameter Name="SecNo" Type="String" />
						<asp:parameter Name="Seniority" Type="String" />
						<asp:parameter Name="Radio" Type="String" />
						<asp:parameter Name="Locker" Type="String" />
					</InsertParameters>
				</asp:AccessDataSource>
			</div>
			<br />
			<br />
			<br />
			<br />
			<table style="width: 1100px" cellpadding="0" cellspacing="0" class="style15">
				<tr>
					<td class="style16">&nbsp;</td>
				</tr>
				<tr>
					<td class="style12">&nbsp;</td>
				</tr>
			</table>
			<br />
			<asp:AccessDataSource runat="server" ID="AccessDataSource11" DataFile="personnel.mdb" SelectCommand="SELECT DISTINCT [RDO] FROM [Dropdown]">
			</asp:AccessDataSource>
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			<br />
			</td>
		</tr>
	</table>
</form>

</body>

</html>

Open in new window

Avatar of BOEING39
BOEING39

ASKER

No Help!   Looking for help with the my code not references.   I have already research the libraries.

Instead of doing that

set the last parameter as Parameter instead of Control Parameter

then in Selecting event of the datasource set it like

e.Command.Parameters["Job"] and set its value to list of selected values by looping.
Thx for the response.  Not sure what you mean.   Can you give me a better example of the code?

ASKER CERTIFIED SOLUTION
Avatar of Praveen Venu
Praveen Venu
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Still am not getting it.  
I am not a big fan of looking through a lot code to find a solution.  It might be easier, if you could show the ListBox HTML, the GridView's data source HTML, and how you are specifying the parameters for the data source.
Sorry it took so long to get back.   Here is the HTML format.   Basically, my list box will only filter by a single item even though I have multiple selected.   In this case (see HTML) the station ("ListSTA") only filters by the a single item.  I have included the screen shots as request along with the select code.
expertexch1.doc