Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to do the sorting in grid with the three fields. i have user name ,sign in sign out time in grid.

so firstly i want to do the sorting by user name and then if single user have 3 data in grid, so it also sort by latest one in time. i store the datetime in database.


i also try like...

SQL
GridView1.DataSource = c.getdata("select user_name,sign_in,sign_out,document_name from user_log where left(sign_in,10)='" + txt_date.Text + "' order by user_name asc,sign_out desc");
        GridView1.DataBind();


so, if single user have multiple logs in database the latest one of user come first and then second and so on....


Thanks.....
Mitesh
Posted
Comments
Sandeep Mewara 31-May-12 1:48am    
And the issue is?
[no name] 31-May-12 1:53am    
dear i have data like...
31/5/2012 11:21 AM and if one user log in more time then in grid first of all display in asc order with latest one time he enter at last.
Sunasara Imdadhusen 31-May-12 1:59am    
Not clear!!
[no name] 31-May-12 2:03am    
i have three three fields in grid..
1.name of user 2. sign in time 3. sign out time
so there is mutiple entries of same user as sign in time in system and sign out time from system. so i want to display the user name in ascending order as well as the last time he enter the system display first in his/her user list...

1 solution

Try this:
SQL
select user_name,sign_in,sign_out,document_name
from user_log
where left(sign_in,10)='" + txt_date.Text + "'
order by user_name asc, sign_in asc, sign_out desc
 
Share this answer
 
Comments
[no name] 31-May-12 4:07am    
but in sign in and sign out time stored as i.e. 31/05/2012 01:36:22 format

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