
想要的结果是:
用户13: 出纳人员,会计人员,客户管理人员,合同管理员
--------------------------------------------------------------------------
前台Gridview控件代码
-------------------------------------------------------------------------
<asp:TemplateField HeaderText="职位(角色)">
<ItemTemplate>
<%# GetPosition(Eval("id"))%>
</ItemTemplate>
</asp:TemplateField>
-----------------------分割线----------------------------------------
protected string GetPosition(object id)
{
try
{
string positon="";
string sql = "select b.title from A_RoleEmpRelation a ,A_Role b where a.roleid=b.id and a.empid='" + id.ToString() + "' group by b.title";
DataTable dt = Class1.ExecSel(sql);
if (dt.Rows.Count > 0)
{
int i = dt.Rows.Count;
positon += dt.Rows[0]["title"].ToString() + ",";
positon = positon.Substring(0, positon.Length - 1);
return positon;
}
else
return null;
}
catch
{
return null;
}
}