Filtre GridView avec DropDownList
Bonjour à tous,
je chercher à filtrer un GridView avec des listes déroulantes (une DropDownList par champ),
voici mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
<div class="element_corps">
<center><h3><b style="color: #FFFFFF">ELECTRE</b></h3></center>
<hr />
<table>
<tr>
<td>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
DataSourceID="SqlDataSource_EAN" DataTextField="EAN"
DataValueField="EAN" AppendDataBoundItems="true">
<asp:ListItem Value="%">All</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="true"
DataSourceID="SqlDataSource_Editor" DataTextField="Editor"
DataValueField="Editor" AppendDataBoundItems="true">
<asp:ListItem Value="%">All</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="true"
DataSourceID="SqlDataSource_Distributor" DataTextField="Distributor"
DataValueField="Distributor" AppendDataBoundItems="true">
<asp:ListItem Value="%">All</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="DropDownList4" runat="server" AutoPostBack="true"
DataSourceID="SqlDataSource_TVA" DataTextField="TVA"
DataValueField="TVA" AppendDataBoundItems="true">
<asp:ListItem Value="%">All</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="DropDownList5" runat="server" AutoPostBack="true"
DataSourceID="SqlDataSource_DISP" DataTextField="DISP"
DataValueField="DISP" AppendDataBoundItems="true">
<asp:ListItem Value="%">All</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="DropDownList6" runat="server" AutoPostBack="true"
DataSourceID="SqlDataSource_Intergrate_date" DataTextField="Integrate_date"
DataValueField="Integrate_date" AppendDataBoundItems="true">
<asp:ListItem Value="%">All</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="DropDownList7" runat="server" AutoPostBack="true"
DataSourceID="SqlDataSource_File_Name" DataTextField="File_Name"
DataValueField="File_Name" AppendDataBoundItems="true">
<asp:ListItem Value="%">All</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
<asp:SqlDataSource ID="SqlDataSource_EAN" runat="server"
ConnectionString="<%$ ConnectionStrings:DWHConnectionString3 %>"
SelectCommand="SELECT DISTINCT [EAN] FROM [Rejection_Data] ORDER BY [EAN]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource_Editor" runat="server"
ConnectionString="<%$ ConnectionStrings:DWHConnectionString3 %>"
SelectCommand="SELECT DISTINCT [Editor] FROM [Rejection_Data] ORDER BY [Editor]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource_Distributor" runat="server"
ConnectionString="<%$ ConnectionStrings:DWHConnectionString3 %>"
SelectCommand="SELECT DISTINCT [Distributor] FROM [Rejection_Data] ORDER BY [Distributor]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource_TVA" runat="server"
ConnectionString="<%$ ConnectionStrings:DWHConnectionString3 %>"
SelectCommand="SELECT DISTINCT [TVA] FROM [Rejection_Data] ORDER BY [TVA]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource_DISP" runat="server"
ConnectionString="<%$ ConnectionStrings:DWHConnectionString3 %>"
SelectCommand="SELECT DISTINCT [DISP] FROM [Rejection_Data] ORDER BY [DISP]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource_Intergrate_date" runat="server"
ConnectionString="<%$ ConnectionStrings:DWHConnectionString3 %>"
SelectCommand="SELECT DISTINCT [Integrate_date] FROM [Rejection_Data] ORDER BY [Integrate_date] DESC"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource_File_Name" runat="server"
ConnectionString="<%$ ConnectionStrings:DWHConnectionString3 %>"
SelectCommand="SELECT DISTINCT [File_Name] FROM [Rejection_Data] ORDER BY [File_Name]"></asp:SqlDataSource>
<div style="vertical-align:top; height:600px; width:100%; overflow:auto;">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
BackColor="#CCCCCC" DataSourceID="SqlDataSource1" BorderColor="#CCCCCC"
BorderStyle="None" BorderWidth="1px"
CellPadding="3" CellSpacing="2" Width="100%">
<Columns>
<asp:BoundField DataField="EAN" HeaderText="EAN" SortExpression="EAN" />
<asp:BoundField DataField="Editor" HeaderText="Editor"
SortExpression="Editor" />
<asp:BoundField DataField="Distributor" HeaderText="Distributor"
SortExpression="Distributor" />
<asp:BoundField DataField="TVA" HeaderText="TVA" SortExpression="TVA" />
<asp:BoundField DataField="DISP" HeaderText="DISP" SortExpression="DISP" />
<asp:BoundField DataField="Integrate_date" HeaderText="Integrate_date"
SortExpression="Integrate_date" />
<asp:BoundField DataField="File_Name" HeaderText="File_Name"
SortExpression="File_Name" />
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#0099CC" />
<HeaderStyle BackColor="#0099CC" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="White" Font-Bold="True" ForeColor="Black" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="White" Font-Bold="True" />
<SortedAscendingHeaderStyle BackColor="#0099CC" />
<SortedDescendingCellStyle BackColor="White" />
<SortedDescendingHeaderStyle BackColor="#0099CC" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DWHConnectionString3 %>"
SelectCommand="SELECT [EAN], [Editor],
[Distributor], [TVA], [DISP],
[Integrate_date], [File_Name]
FROM [Rejection_Data]"
FilterExpression="[EAN] like '{0}%' and [Editor] like '{1}%' and
[Distributor] like '{2}%' and [TVA] like '{3}%' and
[DISP] like '{4}%' and [Integrate_date] like '{5}%' and
[File_Name] like '{6}%'">
<FilterParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="EAN" PropertyName="SelectedValue" ConvertEmptyStringToNull="false"/>
<asp:ControlParameter ControlID="DropDownList2" Name="Editor" PropertyName="SelectedValue" ConvertEmptyStringToNull="false"/>
<asp:ControlParameter ControlID="DropDownList3" Name="Distributor" PropertyName="SelectedValue" ConvertEmptyStringToNull="false"/>
<asp:ControlParameter ControlID="DropDownList4" Name="TVA" PropertyName="SelectedValue" ConvertEmptyStringToNull="false"/>
<asp:ControlParameter ControlID="DropDownList5" Name="DISP" PropertyName="SelectedValue" ConvertEmptyStringToNull="false"/>
<asp:ControlParameter ControlID="DropDownList6" Name="Integrate_date" PropertyName="SelectedValue" ConvertEmptyStringToNull="false"/>
<asp:ControlParameter ControlID="DropDownList7" Name="File_Name" PropertyName="SelectedValue" ConvertEmptyStringToNull="false"/>
</FilterParameters>
</asp:SqlDataSource>
</div>
</div>
</asp:Content> |
Je n'ai pas d'erreur de compilation mais les listes de trient pas, et rien est affiché quand tout est à "All".
Pourriez-vous me dire ce qui ne va pas dans le code ?
Merci d'avance pour vos réponses !