在Gridview中对三个字段进行排序 [英] Sorting with Three FIelds in Gridview

查看:100
本文介绍了在Gridview中对三个字段进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对三个字段进行网格排序.我有用户名,请在网格中登录注销时间.

所以首先我想按用户名进行排序,然后如果单个用户在网格中有3个数据,那么它也按最新的时间进行排序.我将日期时间存储在数据库中.


我也尝试像...

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...

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();



因此,如果单个用户在数据库中有多个日志,则最新的用户是第一位,然后是第二位,依此类推....


谢谢....
Mitesh



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


Thanks.....
Mitesh

推荐答案

尝试一下:
Try this:
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


这篇关于在Gridview中对三个字段进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆