【发布时间】:2016-08-08 07:15:52
【问题描述】:
我有一个dropdownlist,其值由一个查询绑定,该查询是
select emp_card_no,
emp_name + '-'
+ cast(emp_card_no as varchar)
+ '('
+ datename(MM,a.dt_of_leave)
+ ' - '
+ cast(year(a.dt_of_leave)as varchar)
+')' emp_name
from emp_mst a
where month(a.dt_of_leave) >= month(getdate())-1
and year(a.dt_of_leave) =
case when month(getdate())=1 then year(getdate())-1
else year(getdate())
end
order by emp_name
其结果看起来像这样。
[![SQL 输出][1]][1]
现在我想要的是,在Emp_name 列中,我想根据下面的查询在(April - 2016) 之后添加文本为PROCESS 或PENDING
select emp_mkey, * from emp_mon_day
where emp_mkey = 312
and month = 4
and year = 2016
如果查询返回任何结果,则 PROCESS 否则 PENDING。
注意
第一个查询列Emp_card_no 是emp_mon_day 表中的Emp_mkey。
另见绑定下拉列表的代码
protected void funfillEmployee()
{
DataTable DtCombo = new DataTable();
string strdate = System.DateTime.Now.ToString("dd/MM/yyyy");
DtCombo = ObjPriDal.ExecuteDataTable("select emp_card_no, emp_name + '-' + cast(emp_card_no as varchar)+ '(' + datename(MM,a.dt_of_leave) + ' - ' + cast(year(a.dt_of_leave)as varchar)+')' emp_name " +
" from emp_mst a where month(a.dt_of_leave) >= month(getdate())-1 and year(a.dt_of_leave)= case " +
" when month(getdate())=1 then year(getdate())-1 else year(getdate()) end order by emp_name ");
cmbEmp_Name.DataTextField = "emp_name";
cmbEmp_Name.DataValueField = "emp_card_no";
cmbEmp_Name.DataSource = DtCombo;
cmbEmp_Name.DataBind();
cmbEmp_Name.Items.Insert(0, new ListItem("--Select--", "0"));
DtCombo.Clear();
}
让我知道该怎么做。
我正在使用SQL-server-2005
【问题讨论】:
标签: sql asp.net sql-server-2005 drop-down-menu