特别要注意此处<td colspan="3"> 没有相关数据 </td> colspan="3"是批GridView有多少列。
代码
1 <asp:GridView ID="grvStudentInfo" runat="server" CssClass="listgrid" AutoGenerateColumns="False"
2 AllowSorting="True" DataKeyNames="ID"
3 OnRowDeleting="grvStudentInfo_RowDeleting"
4 onrowdatabound="grvStudentInfo_RowDataBound">
5 <EmptyDataTemplate>
6 <table style="text-align: center">
7 <tr>
8 <th style="width: 100px;">
9 学生姓名
10 </th>
11 <th>
12 学号
13 </th>
14 <th>
15 删除
16 </th>
17 </tr>
18 <tr align="center">
19 <td colspan="3">
20 没有相关数据
21 </td>
22 </tr>
23 </table>
24 </EmptyDataTemplate>
25 <Columns>
26 <asp:BoundField DataField="StudentName" HeaderText="学生姓名" />