Как отобразить всех сотрудников под каждым менеджером
I have a 2 tables: Mrg: UserID || UserID_Mrg || Status and User: UserID || Name I want to display all employees (UserID) under each Manager (UserID_Mrg) example: UserID_Mrg = 12 So display all UserID with UserID_Mrg = 12 so far I could just display the users Information an their Manager:
Что я уже пробовал:
<pre lang="c#">private void BindGridView() { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString)) using (SqlDataAdapter adapter = new SqlDataAdapter(@" SELECT tbl_user.Name, tbl_mrg.UserID_Mrg FROM tbl_mrg INNER JOIN tbl_user ON tbl_mrg.UserID = tbl_user.UserID WHERE ((tbl_mag.user_ID = @UserID)) ORDER BY tbl_user.Name", con)) { adapter.SelectCommand.Parameters.Add(new SqlParameter("@UserID", SessionHelper.UserID)); adapter.Fill(Data2); GridView2.DataSource = Data2; GridView2.DataBind(); } }
<asp:GridView ID="GridView2" runat="server"> <Columns> <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /> <asp:BoundField DataField="Mrg" HeaderText="Manager" SortExpression="Manager" /> </Columns> </asp:GridView>