日期:2014-05-17  浏览次数:20442 次

这个数据该怎么判断啊
SQL code
SELECT
    A.ID,
    A.AccountID,
    B.OrganFullName,
    A.AccountType,
    B.OrganShortName,
    C.StageName,
    A.AddTime
 FROM AccountInfo A  
join OrganInfo B on A.StageID=B.OrganID
 left join StageInfo C on A.StageID=C.StageID


AccountType是用户类型,如果为1那么就在界面上显示OrganShortName的值,如果为0就显示StageName的值,在哪里判断比较好呢?下面是界面上的绑定
C# code
 <td>
                                <%#Eval("AccountType")%>&nbsp;
                            </td>


------解决方案--------------------
探讨
三元运算符 来判定

HTML code

<td>
<%#DataBinder.Eval(Container.DataItem, "AccountType", "{0} ") ==1 ? DataBinder.Eval(Container.DataItem, "OrganShortName", "{0} "):
DataBinder.Eval(Container.DataItem, "S……

------解决方案--------------------
SELECT A.ID, A.AccountID, B.OrganFullName, A.AccountType, B.OrganShortName, C.StageName, A.AddTime , CASE WHEN AccountType='1' THEN OrganShortName WHEN AccountType='0' THEN StageName END SSS FROM AccountInfo A join OrganInfo B on A.StageID=B.OrganID left join StageInfo C on A.StageID=C.StageID