我有一个连接到 DataSqlSource 的网格视图。我想通过下拉列表动态排序我的查询。例如按日期、姓名、家庭等。我还在查询中加入了一些表。我在我的 DataSqlSource 中使用此代码:
SELECT AddTitle.Title, SubmitManuscript.Status, AddArticleType.Type, AddArticleType.UserName, AddArticleType.ArticleType, SubmitManuscript.date, SubmitManuscript.ArticleNum, AddArticleType.ArticleID, CONVERT (VARCHAR(10), SubmitManuscript.date, 103) AS date1, OtherWritter.ArticleID AS Expr1, OtherWritter.name, OtherWritter.family, AddArticleType.CheckFinish FROM AddArticleType INNER JOIN AddTitle ON AddArticleType.ArticleID = AddTitle.ArticleID INNER JOIN SubmitManuscript ON AddArticleType.ArticleID = SubmitManuscript.ArticleID INNER JOIN OtherWritter ON AddTitle.ArticleID = OtherWritter.ArticleID WHERE (AddArticleType.ArticleID IN (SELECT ArticleID FROM AddUpload_4 AS AddUpload_4_1 WHERE (AddArticleType.CheckFinish = '0'))) AND (AddArticleType.Type = @Type) AND (SubmitManuscript.Status = 'Accept') AND
(OtherWritter.MainAuthor = 'Yes') ORDER BY '[' + @SortOrder + ']' DESC
但这对我不起作用,也没有排序发生!
我也尝试了这段代码,这次它给了我一个错误:这是代码:
SELECT ...
FROM ...
ORDER BY
CASE WHEN @order=Country THEN Country END DESC,
CASE WHEN @order= City THEN City END ASC,
CASE WHEN @order= name THEN name END ASC
有谁能够帮助我?