在C#中以列表视图显示绑定数据 [英] Dispaly bind data in listview in C#

查看:242
本文介绍了在C#中以列表视图显示绑定数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想绑定类型的worker信息。 emplyee表和casualstaff表是相互关联的。当我在ComboBox中选择Permanent时,我希望显示所有不包括来自casualstaff表的平铺员工,当我选择休闲组合框显示所有休闲员工时。



我尝试过:



I want to bind the worker information for type. The emplyee table and casualstaff table are linked. When I Choose the Permanent in ComboBox I want to display all of the parment staffs not include from the casualstaff table and when I choose the casual in combobox display all the casual staffs.

What I have tried:

DECLARE	@Staff_Type Varchar(10)

SELECT 
		'Employee Id' 	= EE.StaffID
	,	'Name'  	= RTRIM(LTRIM(EE.Name))

	FROM 
		Employee 		EE
		CasualStaff		CS
	WHERE 	(EE.StaffID=CS.StaffID
			@Staff_Type='Casual')
	OR		(EE.StaffID!=CS.StaffID
			@Staff_Type='Permanent')

推荐答案

你的问题并不完全清楚,但我猜你想要这样的东西:

Your question isn't completely clear, but I'm guessing you want something like this:
SELECT
    'Employee Id' = EE.StaffID,
    'Name' = RTRIM(LTRIM(EE.Name))
FROM
    Employee As EE
WHERE
(
    @Staff_Type = 'Casual'
And
    Exists
    (
        SELECT 1
        FROM CasualStaff As CS
        WHERE CS.StaffID = EE.StaffID
    )
)
Or
(
    @Staff_Type = 'Permanent'
And
    Not Exists
    (
        SELECT 1
        FROM CasualStaff As CS
        WHERE CS.StaffID = EE.StaffID
    )
)



注意: Employee 表上有一个标志可能更简单,以表明雇用的类型EE;但这取决于您使用 CasualStaff 表的其他内容。


NB: It would probably be simpler to have a flag on the Employee table to indicate the type of employee; but that depends on what else you're using the CasualStaff table for.


这篇关于在C#中以列表视图显示绑定数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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