1

我需要Request.QueryString在我的asp:SqlDataSource?

 <asp:SqlDataSource runat="server" 
                    ID="SqlDataSource2" ConnectionString='<%$ ConnectionStrings:messageexchangeConnectionString %>' 
                    ProviderName='<%$ ConnectionStrings:messageexchangeConnectionString.ProviderName %>' 
                    SelectCommand='SELECT distribution_address FROM exchange_distribution_groups ex WHERE (organisation_id = 'Request.QueryString["organisation"]') AND (distribution_address NOT IN (SELECT distribution_address FROM exchange_distribution_group_addresses address))'>     
 </asp:SqlDataSource>
4

2 回答 2

2

尝试这个:

<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConnectionString="<%$ ConnectionStrings:messageexchangeConnectionString %>" 
    SelectCommand="SELECT organisation_id,distribution_address FROM exchange_distribution_groups ex WHERE (([organisation_id] = @id) AND (distribution_address NOT IN (SELECT distribution_address FROM exchange_distribution_group_addresses address))">
    <SelectParameters>
        <asp:QueryStringParameter Name="id" QueryStringField="organisation" Type="Int32" />
    </SelectParameters>
</asp:SqlDataSource>
于 2013-09-06T09:29:36.693 回答
2

你可以用这个

     <asp:SqlDataSource runat="server" ID="SqlDataSource2"
         ConnectionString='<%$ ConnectionStrings:messageexchangeConnectionString %>'
         ProviderName='<%$ ConnectionStrings:messageexchangeConnectionString.ProviderName %>'
         SelectCommand='SELECT distribution_address FROM exchange_distribution_groups ex WHERE (organisation_id = '<%# Request.QueryString["organisation"] %> ') AND (distribution_address NOT IN (SELECT distribution_address FROM exchange_distribution_group_addresses address))'>    
     </asp:SqlDataSource>
于 2013-09-06T09:20:58.640 回答