Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parameterized Query
Message
 
 
À
21/09/2009 20:42:57
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01425528
Message ID:
01425531
Vues:
43
>First foray into .NET so please be gentle............
>
>Please note: there are extra spaces in the code near the < > tags. UT could not accept the original formatting
>
>Following an example in an online tutorial I have the following code
>    < asp:SqlDataSource ID="myFilteringDataSource" runat="server"
>        ConnectionString="< %$ ConnectionStrings:RLP_SPOTLIGHTConnectionString % >" 
>        ProviderName="< %$ ConnectionStrings:RLP_SPOTLIGHTConnectionString.ProviderName % >" 
>        SelectCommand="SELECT DISTINCT buyer_type FROM open_order"
>    / >
>    < asp:DropDownList ID="myDropDownList" runat="server"
>        DataSourceID   = "myFilteringDataSource"
>        DataValueField = "buyer_type"
>        AutoPostBack   = "True"
>     / >
>
>    <br />
>    <br />
>    < asp:SqlDataSource ID="MySqlOpen_Order" runat="server" 
>        ConnectionString="< %$ ConnectionStrings:RLP_SPOTLIGHTConnectionString % >" 
>        ProviderName="< %$ ConnectionStrings:RLP_SPOTLIGHTConnectionString.ProviderName % >" 
>        SelectCommand="SELECT * FROM open_order">      
>    < /asp:SqlDataSource >
>
>
>    < asp:GridView ID="GridView1" runat="server" DataSourceID="MySqlOpen_Order" 
>                             etc
>
>This code works in that both the dropdown list and the grid display properly.
>
>Again based on sample code from the tutorial I've tried to modify the code to have the grid based upon the value of the dropdown
>with the modified code as follows
>< asp:SqlDataSource ID="MySqlOpen_Order" runat="server" 
>     ConnectionString="< %$ ConnectionStrings:RLP_SPOTLIGHTConnectionString % >" 
>     ProviderName="< %$ ConnectionStrings:RLP_SPOTLIGHTConnectionString.ProviderName % >" 
>     SelectCommand="SELECT * FROM open_order where buyer_type = @buyer_type">      
>        
>     < SelectParameters>
>      < asp:ControlParameter Name="buyer_type" ControlID="myDropDownList" PropertyName="SelectedValue" / >
>    < /SelectParameters>
>< /asp:SqlDataSource>
>
>When this version of the code runs the dropdown list appears but the grid never gets populated. Selecting a new value from the dropdown doesn't do anything.
>
>All suggestions gratefully appreciated
>
>.........Rich

Hi Rich,

1. Try to set AutoPostBack property of the DropDown to true

2. If, for some unknown reason, declarative syntax would not work for you, you can always use code behind and selecting event of SQLDataSource to set your parameter.

Check this blog
http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/setting-sqldatasource-parameter-from-the
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform