阳光网驿-企业信息化交流平台【DTC零售连锁全渠道解决方案】

 找回密码
 注册

QQ登录

只需一步,快速开始

扫描二维码登录本站

手机号码,快捷登录

老司机
查看: 2377|回复: 0

[转帖] Gridview无数据时显示表头的问题

[复制链接]
  • TA的每日心情
    开心
    2021-8-30 00:00
  • 签到天数: 35 天

    [LV.5]常住居民I

    发表于 2008-9-8 16:29:36 | 显示全部楼层 |阅读模式
    提供了个EmptyDataTemplate,可以把header的样式构造到里面去

    1. <asp:GridView ID="grdvList" runat="server" AutoGenerateColumns="False" CssClass="DataGrid" Width="720px"
    2. DataKeyNames="ROW_REF_ID" OnRowCommand="grdvList_RowCommand" AllowPaging="True" AllowSorting="True"
    3. PageSize="5" OnPageIndexChanging="grdvList_PageIndexChanging" OnSorting="grdvList_Sorting">
    4. <HeaderStyle CssClass="grid_head" />
    5. <RowStyle CssClass="grid_row" />
    6. <SelectedRowStyle CssClass="grid_row_selected" />
    7. <Columns>
    8. <asp:BoundField HeaderText="Action Code" DataField="ACTION_CODE" SortExpression="ACTION_CODE" >
    9. <HeaderStyle Width="200px" />
    10. </asp:BoundField>
    11. <asp:BoundField HeaderText="Description" DataField="ACTION_DESCRIPTION" SortExpression="ACTION_DESCRIPTION" />
    12. <asp:ButtonField HeaderText="Detail" CommandName="Detail" Text="<img src="../Images/BMG_icon_detail.GIF" alt='Detail'; border=0>" >
    13. <HeaderStyle Width="45px" />
    14. </asp:ButtonField>
    15. <asp:ButtonField HeaderText="Delete" CommandName="InActive" Text="<img src="../Images/BMG_icon_delete.GIF" border=0; alt='delete'>">
    16. <HeaderStyle Width="45px" />
    17. </asp:ButtonField>
    18. <asp:ButtonField HeaderText="Active" CommandName="Active" Text="<img src="../Images/BMG_icon_detail.GIF" border=0; alt='active'>">
    19. <HeaderStyle Width="45px" />
    20. </asp:ButtonField>
    21. <asp:BoundField HeaderText="ROW_REF_ID" DataField="ROW_REF_ID" Visible="False" />
    22. </Columns>
    23. <EmptyDataTemplate>
    24. <table frame="void" cellspacing="0" cellpadding="0" border="1" style="width:720px;border-collapse:collapse;">
    25. <tr class="grid_head">
    26. <th scope="col" style="width:200px;">Action Code</th>
    27. <th scope="col">Description</th>
    28. <th scope="col" style="width:45px;">Detail</th>
    29. <th scope="col" style="width:45px;">Delete</th>
    30. </tr>
    31. <tr class="grid_row">
    32. <td colspan="4" align="right">1</td>
    33. </tr>
    34. </table>
    35. </EmptyDataTemplate>
    36. </asp:GridView>
    复制代码
    楼主热帖
    启用邀请码注册,提高发帖质量,建设交流社区
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    快速回复 返回顶部 返回列表