I have a datagrid with sorting/paging. Currently, i have the sql in my page but i want to move it to a stored proc. <BR>I have an "order by" clause in there that uses the viewstate and sort oder. Wondering how to do my Stored Proc..<BR><BR>This is what I have:<BR><BR> cmd.CommandText = "select whatever from table where " & _<BR> " whatevercriteria " & _<BR> " order by " _<BR> & viewstate("sortField").ToString() & " " & viewstate("sortDirection").ToString() <BR><BR>How can I move that to the stored proc? should I not do an "order by", should I leave the sql in the code and not use SP for this sql?<BR><BR>thanks.