Ciao,
stò cercando di implementare una semplice gridview filtrata da delle semplici dropdownlist..ma non ci riesco perchè i valori nella clausola where sono sempre valorizzati!
questo è il codice:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="study_code" HeaderText="Study Code" />
<asp:BoundField DataField="generic_name" HeaderText="Generic name" />
<asp:BoundField DataField="commercial_name" HeaderText="Commercial name " />
<asp:TemplateField HeaderText="Profile">
<ItemTemplate>
<asp:HyperLink runat="server" ImageUrl="images/arrow.gif" NavigateUrl="registry_detail.aspx?id=<%# Eval('id_clinical_profile') %>"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [id_clinical_profile], [study_code], [commercial_name], [generic_name] FROM [clinical_profiles] WHERE (([id_recruitment_status] = @id_recruitment_status) AND ([id_therapeutic_area] = @id_therapeutic_area) AND ([study_code] LIKE '%' + @study_code + '%'))">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList2" Name="id_recruitment_status" PropertyName="SelectedValue"
Type="Int32" />
<asp:ControlParameter ControlID="DropDownList1" Name="id_therapeutic_area" PropertyName="SelectedValue"
Type="Int32" />
<asp:ControlParameter ControlID="gen_search" Name="study_code" PropertyName="Text"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
questa è la TABLE dove ci sono le drodownlist
<table width="440" height="30" border="0" cellpadding="0" cellspacing="0" bgcolor="#DFEAF4">
<tr valign="middle">
<td width="130" style="padding-left:5px"><strong>Generic Search </strong></td>
<td style="padding-left:5px"><asp:TextBox ID="gen_search" runat="server" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; height:18px; width:230px; "></asp:TextBox>
<input type="submit" name="submit" value="GO" style="font-weight:bold; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif;" />
</td>
</tr>
</table>
<p> </p>
<table width="440" border="0" cellpadding="0" cellspacing="0">
<tr valign="middle" bgcolor="#E6E6E6">
<td width="130" height="30" style="padding-left:5px"><strong>Specific search </strong></td>
<td style="padding-left:5px"> </td>
</tr>
<tr valign="middle">
<td height="1" colspan="2"><img src="../../pics/blank.gif" width="1" height="1"></td>
</tr>
<tr valign="middle" bgcolor="#EFEFEF">
<td height="30" style="padding-left:5px">Therapeutic area:</td>
<td style="padding-left:5px">
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2"
DataTextField="therapeutic_area" DataValueField="id_therapeutic_area" OnDataBound="DropDownList1_DataBound">
<asp:ListItem Selected="True" Value="-1">--></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [id_therapeutic_area], [id_lang], [therapeutic_area] FROM [therapeutic_area] WHERE ([id_lang] = @id_lang)">
<SelectParameters>
<asp:SessionParameter DefaultValue="1" Name="id_lang" SessionField="id_lang" Type="Byte" />
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
<tr valign="middle">
<td height="1" colspan="2"><img src="../../pics/blank.gif" width="1" height="1"></td>
</tr>
<tr valign="middle" bgcolor="#EFEFEF">
<td height="30" style="padding-left:5px">Recruitment status:</td>
<td style="padding-left:5px">
<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource3"
DataTextField="recruitment_status" DataValueField="id_recruitment_status" OnDataBound="DropDownList2_DataBound">
<asp:ListItem Value="-1">--></asp:ListItem>
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [id_recruitment_status], [id_lang], [recruitment_status] FROM [recruitment_status] WHERE ([id_lang] = @id_lang)">
<SelectParameters>
<asp:SessionParameter DefaultValue="1" Name="id_lang" SessionField="id_lang" Type="Byte" />
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
<tr valign="middle">
<td height="1" colspan="2"><img src="../../pics/blank.gif" width="1" height="1"></td>
</tr>
<tr valign="middle" bgcolor="#EFEFEF">
<td height="30" style="padding-left:5px"></td>
<td style="padding-left:5px">
<input type="submit" name="submit" value="GO" style="font-weight:bold; font-size:10px; font-family:Verdana, Arial, Helvetica, sans-serif;" />
</td>
</tr>
</table>
[/code>
Ma perchè è cosi complicato??
Qualcuno che mi sà aiutare? thx
Modificato da satoshy il 13 dicembre 2006 14.12 -