Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm using an SqlDataSource and gridview to display some data, the data being displayed related to the url parameter. So in my case, my url paramter is ?orderid={number} and I want to use that for my query. I've been fiddling about but cant seem to get anywhere with it.

Here is my code;

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ 

    ConnectionStrings:ConnectionString %>" SelectCommand="
        SELECT f.filmID, f.filmTitle, f.filmPrice 
        FROM films f 
        INNER JOIN orderItems o 
        ON f.filmID = o.filmID 
        WHERE (o.orderID = @orderID)">
        <SelectParameters>
            <asp:QueryStringParameter Name="orderID" QueryStringField="orderid" />
        </SelectParameters>

</asp:SqlDataSource>
share|improve this question

1 Answer 1

up vote 0 down vote accepted

This looks correct. If it is not working, I would try adding a DbType, DefaultValue and/or ConvertEmptyStringToNull paramenter.

DbType –The Data Type of the SQL Parameter DefaultValue (Optional) – Here you can specify the Default Value of the Parameter when the QueryString Parameter is missing or not supplied. ConvertEmptyStringToNull (Optional) – As the Name suggests this will set the Parameter value to NULL when it is empty or blank.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.