我有三个表1)经理,2)Teamleader,3)代理。 我想表明有多少经纪人特别是经理,就像我在图像中所示,娜塔莎,奥迪亚都在下本,艾玛在乔尼之下,但两人都在约翰之下。我想在datalist中显示这些代理列表
我使用此代码:
string agent = Session["UserEmail"].ToString();
ArrayList Course = new ArrayList();
string query = "select Email_ID from tblTeamLeaders where IsActive_By='" + agent + "'";
using (SqlCommand cm = new SqlCommand(query, conn))
{
conn.Open();
SqlDataReader reader = cm.ExecuteReader();
while (reader.Read())
{
Course.Add(reader.GetString(0));
}
conn.Close();
}
foreach (string value in Course)
{
conn.Open();
string str = "select DISTINCT name from [tblAgents] where IsActive='True' and IsActive_By='" + value + "'";
SqlCommand cmd = new SqlCommand(str, conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
DataList1.DataSource = ds;
DataList1.DataBind();
conn.Close();
}