Ask a Question related to Adobe Dreamweaver & Contribute, Design and Development.
-
davidxtaylor #1
ORDER BY clause in asp.net dataset
I have an aspx page on which is a dataset created in DWMX. The sql query is
described in the line CommandText='<%# 'SELECT * FROM booklist ' %>' I want
to be able to sort the list and the consequent page in different ways
dynamically. In classic ASP I would do this by passing a querystring back to
the page (like pasge.asp?sortorder=id) and it was easy to fix the querystring
to accept a parameter. But in .net I cant do this, I have tried adding a
parameter in the MX query-invoking dialog but the result CommandText='<%#
'SELECT * FROM booklist ORDER BY @sortorder' %>' - although it tests
correctly in the dialog - once sent and tested on the server produces an SQL
server message saying that I must supply a column name in order to be able to
use ORDER BY. (but I am !!) I can use CommandText='<%# 'SELECT * FROM
booklist ORDER BY ' + request.querystring('sortorder') %>' , that works but of
course falls over if the page is called without the querystring. Can anyone
help me in re-sorting a datalist dynamically?
davidxtaylor Guest
-
Re-arranging order of DataSet
Is it possible to re-arrange the order of the dataset, not just sort it. If you have a look at: http://www.ducksoupdesign.net/tak/stock/ You... -
Strange results of ORDER BY clause when item begins with slash orbackslash
I am seeing some unexpected results for an ORDER BY in a query. It looks to me as if the sorting is confused about how to handle the slash or... -
Where Clause: Order of Precedence
Here's my WHERE clause on an SQL statement I wrote: WHERE blnLive = TRUE AND blnVacPromo = TRUE AND (dtToPost <= Now() AND dtToRemove > Now() ) ... -
Trouble with ORDER BY clause
Hi all I'm not sure ASP is the problem, but my SQL statement seems fine to me. This works fine : strSQL = "SELECT .* FROM _RechPat INNER JOIN... -
ORDER BY clause causes read-only recordset
I have a website with some asp pages running off of a MS Sql db. For reasons that I can't explain, whenever querying the database with a SELECT... -
ossie #2
Re: ORDER BY clause in asp.net dataset
Hi
I had exactly the same problem with a site I did last year
(pharmacyhealthlink.org)
Basically I did something like this, checked to see if param was available
and if not set a default
<script runat="server>
dim mySortOrder
dim myCmd
sub page_load
if Request.Params("sortorder") = "" then
mySortOrder = "ASC"
else
mySortOrder = Request.Params("sortorder")
end if
myCmd = "Select * from booklist Order By " + mySortOrder
end sub
</script>
And then
CommandText='<%# myCmd %>'
Hope this helps
"davidxtaylor" <webforumsuser@macromedia.com> wrote in message
news:cv7k9h$q9a$1@forums.macromedia.com...>I have an aspx page on which is a dataset created in DWMX. The sql query is
> described in the line CommandText='<%# 'SELECT * FROM booklist ' %>' I
> want
> to be able to sort the list and the consequent page in different ways
> dynamically. In classic ASP I would do this by passing a querystring back
> to
> the page (like pasge.asp?sortorder=id) and it was easy to fix the
> querystring
> to accept a parameter. But in .net I cant do this, I have tried adding a
> parameter in the MX query-invoking dialog but the result CommandText='<%#
> 'SELECT * FROM booklist ORDER BY @sortorder' %>' - although it tests
> correctly in the dialog - once sent and tested on the server produces an
> SQL
> server message saying that I must supply a column name in order to be able
> to
> use ORDER BY. (but I am !!) I can use CommandText='<%# 'SELECT * FROM
> booklist ORDER BY ' + request.querystring('sortorder') %>' , that works
> but of
> course falls over if the page is called without the querystring. Can
> anyone
> help me in re-sorting a datalist dynamically?
>
ossie Guest



Reply With Quote

