-
April 28th, 2010, 07:32 PM
#1
sqlDataSource selectCommand
I am having trouble figuring out how to get my datasource to pull a query with a where clause when it detects a query string and strip the where clause when the parameter is empty.
My datasource query and gridview work as I need them to with my querystring item "?album_id=##", but I want to get at the page without a querystring and thusly strip the where clause out of the select command and show the full query in the gridview.
I tried setting the selectcommand attribute in the .cs on page_load to the proper string if the querystring value is null and that didn't seem to overwrite the old querystring.
Any suggestions?
PHP Code:
<asp:SqlDataSource ID="sdsViewComments" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT album.album_name, comment.commenter_name, comment.comment_pros, comment.comment_cons, comment.rating FROM comment INNER JOIN comment_link ON comment.comment_id = comment_link.comment_id INNER JOIN album ON comment_link.album_id = album.album_id WHERE (album.album_id = @album_id_from_page)"> <SelectParameters> <asp:QueryStringParameter Name="album_id_from_page" QueryStringField="album_id" /> </SelectParameters> </asp:SqlDataSource>
Cheers,
MAtt
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|