Modifying the SqlDataSource SelectCommand prior to loading a page RRS feed

  • Question

  • I have a SqlDataSource setup in the markup on my page. After some new requirements, I am trying to find a way to modify the SelectCommand before the data is filled for the first time. The SelectCommand below will now be used by default since we'll always have the first param. I am faced with a need to modify the SelectCommand though, adding a second session parameter along with it. I tried to override the OnInit method but it didn't seem to still used the default query. Is there a best way to accomplish this? Here is the section of markup I am referring to:

        <asp:ScriptManager ID="ScriptManagerCustomerMaintenance" runat="server" EnablePageMethods="true"></asp:ScriptManager>
        <asp:SqlDataSource ID="SqlDataSourceHD" runat="server"
            ConnectionString="<%$ ConnectionStrings:HDOracleConnectionString %>"
            ProviderName="<%$ ConnectionStrings:HDOracleConnectionString.ProviderName %>"
            SelectCommand="SELECT * FROM Customer WHERE (HOME_PHONE=:HOME_PHONE)"
            UpdateCommand="UPDATE Customer SET CustomerEID=:CustomerEID WHERE (HOME_PHONE=:HOME_PHONE)">
                <asp:SessionParameter Name="HOME_PHONE" SessionField="HOME_PHONE" Type="String" />
                <asp:Parameter Name="CustomerEID" Type="String" />
                <asp:Parameter Name="HOME_PHONE" Type="String" />


    Thank you for any assistance anyone can provide here.

    Tuesday, September 28, 2010 8:58 PM