DataGrid 查出一个列 按要求显示格式 例如:操作人(地点)

这是转换DataGrid显示格式之后 连接字符串的方法 显示:操作人(地点)
public static ObservableCollection<CListModel> AllUserList { get { if (_AllUserList == null) { _AllUserList = new ObservableCollection<CListModel>(); var users = UserDal.GetInstance().GetUserByCondition(new XGX_USER()); foreach (var item in users) { StringBuilder sb = new StringBuilder(); sb.Append(item.USER_NAME); if (!string.IsNullOrEmpty(item.USER_PLACE)) { sb.Append("("); sb.Append(item.USER_PLACE); sb.Append(")"); } _AllUserList.Add(new CListModel() { DisplayValue = sb.ToString(), SelectValue = item.USER_ID }); } } return _AllUserList; } }

另一种简单的方法:

 public const string SQL_SELECT_XGX_BALANCE =
            @"
            SELECT 
            T.ID,
            T.SUM,
            T.OPERATOR,
            (U.USER_NAME || '('||U.USER_PLACE||')')  OPERATOR_N, //操作人(地点)
            T.OPERATION_TIME,
            T.STATUS
            FROM 
            XGX_BALANCE T
            LEFT JOIN XGX_USER U
            ON T.OPERATOR=U.USER_ID
            ";

左联 USER表 查出

(U.USER_NAME || '('||U.USER_PLACE||')')  

XAML Binding OPERATOR_N

posted @ 2015-01-28 08:24  歌·颂  阅读(195)  评论(0编辑  收藏  举报