Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am showing orderid, orderdate, customerid, totalamount in a gridview. i want to show the last record at top of a gridview. how can i do it??

C#
 public void bind()
    {
        string query = "select OrderID,CustomerID,OrderDate,totalAmount,Status From Orders";
        DataSet ds = obj.fillgrid(query);
        GridView1.DataSource = ds.Tables[0];
        GridView1.DataBind();
    }
}
Posted
Comments
André Kraak 21-Oct-11 18:57pm    
Let say you have OrderID 1, 2 and 3. Do you want to show the show the records as (3, 2, 1) or (3, 1, 2)?
codegeekalpha 21-Oct-11 19:06pm    
hmm got it..
codegeekalpha 21-Oct-11 19:09pm    
order by orderid desc

1 solution

If you want to show the orders in descending (from high to low) order based on the OrderID then change the SQL query to
SQL
SELECT OrderID,CustomerID,OrderDate,totalAmount,Status FROM Orders ORDER BY OrderID DESC
 
Share this answer
 
Comments
Mohd Wasif 22-Oct-11 1:32am    
Good Answer my +5
codegeekalpha 22-Oct-11 7:16am    
i gave him +5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900