将网格视图行转换为列

时间:2019-05-02 05:29:07

标签: c# asp.net

嗨,我想(旋转/翻转/转置)网格视图RowsColumns

这是带有数据源的网格视图

<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">
<Columns>
  <asp:BoundField DataField="faculty_name" HeaderText="Teacher Name" SortExpression="faculty_name" />
  <asp:BoundField DataField="att_date" HeaderText="Attendance Date" SortExpression="att_date" DataFormatString="{0:dd-MM-yyyy}" />
  <asp:CheckBoxField DataField="active" HeaderText="Present" SortExpression="active" />
</Columns>
</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DevdapSchool %>" SelectCommand="SELECT FacultyAttendance.att_date, FacultyAttendance.active, Faculty.faculty_name FROM FacultyAttendance INNER JOIN Faculty ON FacultyAttendance.teacher_id = Faculty.faculty_id WHERE (FacultyAttendance.faculty_id = @faculty_id) AND (FacultyAttendance.school_id = @school_id) ORDER BY FacultyAttendance.att_date">

 <SelectParameters>
  <asp:SessionParameter Name="faculty_id" SessionField="faculty_id" />
  <asp:SessionParameter Name="school_id" SessionField="school_id" />
 </SelectParameters>

</asp:SqlDataSource>

此Gridview显示这样的教师每月出勤情况。 enter image description here

我要显示这样的结果。 enter image description here

0 个答案:

没有答案