Gridview无数据时显示表头的问题

来源:互联网 发布:小额贷款管理系统源码 编辑:程序博客网 时间:2024/04/30 22:50

提供了个EmptyDataTemplate,可以把header的样式构造到里面去

<asp:GridView ID="grdvList" runat="server" AutoGenerateColumns="False" CssClass="DataGrid" Width="720px" 
                       DataKeyNames
="ROW_REF_ID" OnRowCommand="grdvList_RowCommand" AllowPaging="True" AllowSorting="True" 
                         PageSize
="5" OnPageIndexChanging="grdvList_PageIndexChanging" OnSorting="grdvList_Sorting">                         
                        
<HeaderStyle CssClass="grid_head" />
                        
<RowStyle CssClass="grid_row" />
                        
<SelectedRowStyle CssClass="grid_row_selected" />
                        
<Columns>
                            
<asp:BoundField HeaderText="Action Code" DataField="ACTION_CODE" SortExpression="ACTION_CODE" >
                                
<HeaderStyle Width="200px" />
                            
</asp:BoundField>
                            
<asp:BoundField HeaderText="Description" DataField="ACTION_DESCRIPTION" SortExpression="ACTION_DESCRIPTION" />
                            
<asp:ButtonField HeaderText="Detail" CommandName="Detail" Text="&lt;img src=&quot;../Images/BMG_icon_detail.GIF&quot; alt='Detail'; border=0&gt;" >
                                
<HeaderStyle Width="45px" />
                            
</asp:ButtonField>
                            
<asp:ButtonField HeaderText="Delete" CommandName="InActive" Text="&lt;img src=&quot;../Images/BMG_icon_delete.GIF&quot; border=0; alt='delete'&gt;">
                                
<HeaderStyle Width="45px" />
                            
</asp:ButtonField>
                            
<asp:ButtonField HeaderText="Active" CommandName="Active" Text="&lt;img src=&quot;../Images/BMG_icon_detail.GIF&quot; border=0; alt='active'&gt;">
                                
<HeaderStyle Width="45px" />
                            
</asp:ButtonField>
                            
<asp:BoundField HeaderText="ROW_REF_ID" DataField="ROW_REF_ID" Visible="False" />
                         
</Columns>
                         
<EmptyDataTemplate>
                            
<table frame="void" cellspacing="0" cellpadding="0" border="1" style="width:720px;border-collapse:collapse;">
                             
<tr class="grid_head">
                              
<th scope="col" style="width:200px;">Action Code</th>
                              
<th scope="col">Description</th>
                              
<th scope="col" style="width:45px;">Detail</th>
                              
<th scope="col" style="width:45px;">Delete</th>
                          
</tr>
                          
<tr class="grid_row">
                              
<td colspan="4" align="right">1</td>
                          
</tr>
                            
</table>
                         
</EmptyDataTemplate>
                    
</asp:GridView> 

原创粉丝点击