Rows
到Columns
这是带有数据源的网格视图
<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>