Bonjour,
Je suis en auto apprentissage: asp.net + data, j'ai donc une webForm.aspx avec:
Un SqlDataSource qui alimente une DropDownList:
Un deuxième SqlDataSource qui alimente un GridView en prenant en paramètre un OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged1" ==> le problème est ici
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT "DESCRIPTION_PROFIL" FROM "TBL_PROFIL""></asp:SqlDataSource>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT "NOM", "PRENOM", "DESCRIPTION_PROFIL", "PROFIL" FROM "VUE_RECRUTEMENT" WHERE ("DESCRIPTION_PROFIL" = ?)" OnSelecting="SqlDataSource2_Selecting"> OnSelecting="SqlDataSource2_Selecting"> <SelectParameters> <asp:ControlParameter ControlID="DropDownList1" Name="DESCRIPTION_PROFIL" PropertyName="SelectedValue" Type="String" /> </SelectParameters> </asp:SqlDataSource>
Quand j’exécute le projet j'ai une erreur: ORA-00911: caractère non valide à cause du ? que me génère l'assistant de mon SqlDataSource
Mais si force un paramètre directement:
==> ça fonctionne
Code : Sélectionner tout - Visualiser dans une fenêtre à part SelectCommand="SELECT NOM, PRENOM, DESCRIPTION_PROFIL, PROFIL FROM VUE_RECRUTEMENT WHERE DESCRIPTION_PROFIL = 'Informaticien'"
Comment faire pour mettre le contrôle DropDownList en paramètre dans mon SelectCommand ?
Code complet:
D'avance merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <body> <form id="form1" runat="server"> <div> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT "DESCRIPTION_PROFIL" FROM "TBL_PROFIL""></asp:SqlDataSource> <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="DESCRIPTION_PROFIL" DataValueField="DESCRIPTION_PROFIL" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged1"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT "NOM", "PRENOM", "DESCRIPTION_PROFIL", "PROFIL" FROM "VUE_RECRUTEMENT" WHERE ("DESCRIPTION_PROFIL" = ?)" OnSelecting="SqlDataSource2_Selecting"> <SelectParameters> <asp:ControlParameter ControlID="DropDownList1" Name="DESCRIPTION_PROFIL" PropertyName="SelectedValue" Type="String" /> </SelectParameters> </asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="SqlDataSource2" AllowPaging="True" AllowSorting="True"> <Columns> <asp:CommandField ShowSelectButton="True" /> <asp:BoundField DataField="NOM" HeaderText="NOM" SortExpression="NOM" /> <asp:BoundField DataField="PRENOM" HeaderText="PRENOM" SortExpression="PRENOM" /> <asp:BoundField DataField="DESCRIPTION_PROFIL" HeaderText="DESCRIPTION_PROFIL" SortExpression="DESCRIPTION_PROFIL" /> <asp:BoundField DataField="PROFIL" HeaderText="PROFIL" SortExpression="PROFIL" /> </Columns> <FooterStyle BackColor="White" ForeColor="#000066" /> <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" /> <RowStyle ForeColor="#000066" /> <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" /> <SortedAscendingCellStyle BackColor="#F1F1F1" /> <SortedAscendingHeaderStyle BackColor="#007DBB" /> <SortedDescendingCellStyle BackColor="#CAC9C9" /> <SortedDescendingHeaderStyle BackColor="#00547E" /> </asp:GridView> </div> </form> </body>
Partager