修复ASP.NET中的转发器中的标题行 [英] Fix header row in repeater in ASP.NET

查看:79
本文介绍了修复ASP.NET中的转发器中的标题行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚如何在使用asp.net的中继器中修复标题行。试图摆位置时:固定;在tr标签中。它似乎解决了这个问题,但它的尺寸变小了,不适用于桌子的其他部分。



任何提示或帮助正确的方向都会有很大帮助!

感谢

 < div class =form-panel style =font-size:small; text-align:left;> 
< div class =header>
< div class =contentRestrictionstyle =height:22px>
动作公告异常
< asp:button id =addExceptiontext =添加异常runat =serverstyle =float:right; margin-right:20pxonclick =addExceptions />
< / div>
< / div>
< div class =commands>
< div class =contentRestrictionstyle =overflow-y:scroll; width:100%; height:185px>
< asp:repeater id =repExceptionrunat =serverdatasourceid =SP_AB_BULLETIN_EXCEPTION>
< HeaderTemplate>
< div class =form-panelstyle =font-size:small;>
< table class =notepad-tablecellpadding =2cellspacing =0width =100%>
< tr style =background-color:#eeeeee; font-weight:bold;>
< td>日期时间来自< / td>
< td>日期时间到< / td>
< td>状态< / td>
< td>上次修改< / td>
< td>上次修改者< / td>
< td>动作< / td>
< / tr>
< / HeaderTemplate>
< ItemTemplate>
< tr id =tr1runat =server>
< td>
< asp:Literal ID =Literal1runat =serverText ='<%#Eval(EFTV_FROM)%>'/>
< / td>
< td>
< asp:Literal ID =Literal2runat =serverText ='<%#Eval(EFTV_TO)%>'/>
< / td>
< td>
< asp:Literal ID =Literal3runat =serverText ='<%#Eval(AB_STATUS1)%>'/>
< / td>
< td>
< asp:Literal ID =Literal4runat =serverText ='<%#Eval(LAST_MOD_DATE)%>'/>
< / td>
< td>
< asp:Literal ID =Literal6runat =serverText ='<%#Eval(UserName)%>'/>
< / td>
< td>
< asp:Button ID =editExceptionText =Editrunat =serverCommandName =EXIDCommandArgument ='<%#Eval(EX_ID)%>'OnCommand =editException />
< asp:Button ID =deleteExceptionText =Deleterunat =serverCommandName =EXIDCommandArgument ='<%#Eval(EX_ID)%>'OnCommand =deleteException />
< / td>

< / tr>
< / ItemTemplate>
< FooterTemplate>
< / table>
< / div>
< / FooterTemplate>
< / asp:中继器>
< / div>
< / div>
< / div>


解决方案

修改您的代码。

<1>将以下样式规则粘贴到页面的< head> 部分:

 < style type =text / css> 
table tbody,table thead {
display:block;
}

table tbody {
overflow:auto;
height:100px;
}

th,td {
width:150px;
}
< / style>



<2>替换< div class =commands> 与下面的一个:

 < div class =commands> 
< asp:Repeater ID =repExceptionrunat =serverDataSourceID =SP_AB_BULLETIN_EXCEPTION>
< HeaderTemplate>
< div class =form-panelstyle =font-size:small;>
< table class =notepad-tablecellpadding =2cellspacing =0>
< thead>
< tr style =background-color:#eeeeee; font-weight:bold;>
< th>日期时间来自< / th>
< th>日期时间至< / th>
< th>状态< / th>
< th>上次修改时间< / th>
< th>上次修改者< / th>
< th>动作< / th>
< / tr>
< / thead>
< tbody>
< / HeaderTemplate>
< ItemTemplate>
< tr id =tr1runat =server>
< td>
< asp:Literal ID =Literal1runat =serverText ='<%#Eval(EFTV_FROM)%>'/>
< / td>
< td>
< asp:Literal ID =Literal2runat =serverText ='<%#Eval(EFTV_TO)%>'/>
< / td>
< td>
< asp:Literal ID =Literal3runat =serverText ='<%#Eval(AB_STATUS1)%>'/>
< / td>
< td>
< asp:Literal ID =Literal4runat =serverText ='<%#Eval(LAST_MOD_DATE)%>'/>
< / td>
< td>
< asp:Literal ID =Literal6runat =serverText ='<%#Eval(UserName)%>'/>
< / td>
< td>
< asp:Button ID =editExceptionText =Editrunat =serverCommandName =EXIDCommandArgument ='<%#Eval(EX_ID)%>'OnCommand =editException />
< asp:Button ID =deleteExceptionText =Deleterunat =serverCommandName =EXIDCommandArgument ='<%#Eval(EX_ID)%>'OnCommand =deleteException />
< / td>

< / tr>
< / ItemTemplate>
< FooterTemplate>
< / tbody>
< / table>
< / div>
< / FooterTemplate>
< / asp:中继器>
< / div>

输出:


i am trying to figure out how to fix the header row with in the repeater using asp.net. When trying to put position:fixed; in the tr tag. It seems to fix it but it becomes smaller in size and doesn't work with the rest of the table.

any hints or help in the right direction would help significantly!

thanks

<div class="form-panel" style="font-size: small; text-align: left;">
    <div class="header">
        <div class="contentRestriction" style="height: 22px">
            Action Bulletin Exception
            <asp:button id="addException" text="Add Exception" runat="server" style="float: right; margin-right: 20px" onclick="addExceptions" />
        </div>
    </div>
    <div class="commands">
        <div class="contentRestriction" style="overflow-y: scroll; width: 100%; height: 185px">
            <asp:repeater id="repException" runat="server" datasourceid="SP_AB_BULLETIN_EXCEPTION">
                        <HeaderTemplate>
                            <div class="form-panel" style="font-size: small;">
                                <table class="notepad-table" cellpadding="2" cellspacing="0" width="100%" >
                                    <tr style="background-color: #eeeeee; font-weight: bold; ">                                 
                                        <td>Date Time From</td>
                                        <td>Date Time To</td>
                                        <td>Status</td>
                                        <td>Last Modified</td>
                                        <td>Last Modified By</td>
                                        <td>Action</td>
                                    </tr>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <tr id="tr1" runat="server">
                                <td>
                                    <asp:Literal ID="Literal1" runat="server" Text='<%# Eval("EFTV_FROM") %>' />
                                </td>
                                <td>
                                    <asp:Literal ID="Literal2" runat="server" Text='<%# Eval("EFTV_TO") %>' />
                                </td>
                                <td>
                                    <asp:Literal ID="Literal3" runat="server" Text='<%# Eval("AB_STATUS1") %>' />
                                </td>
                                <td>
                                    <asp:Literal ID="Literal4" runat="server" Text='<%# Eval("LAST_MOD_DATE") %>' />
                                </td>
                                <td>
                                    <asp:Literal ID="Literal6" runat="server" Text='<%# Eval("UserName") %>' />
                                </td>
                                <td>
                                    <asp:Button ID="editException" Text="Edit" runat="server"  CommandName="EXID" CommandArgument='<%# Eval("EX_ID") %>' OnCommand="editException" />
                                    <asp:Button ID="deleteException" Text="Delete" runat="server" CommandName="EXID" CommandArgument='<%# Eval("EX_ID") %>' OnCommand="deleteException" />
                                </td>

                            </tr>
                        </ItemTemplate>
                        <FooterTemplate>
            </table> 
        </div>
        </FooterTemplate>
                    </asp:Repeater>      
    </div>
</div>
</div>   

解决方案

To get the fixed header effect you can make two small changes to your code.

1) Paste the following style rules in the <head> section of your page:

<style type="text/css">
    table tbody, table thead {
        display: block;
    }

    table tbody {
        overflow: auto;
        height: 100px;
    }

    th, td {
        width: 150px;
    }
</style>

2) Replace your <div class="commands"> with the one below:

 <div class="commands">
                <asp:Repeater ID="repException" runat="server" DataSourceID="SP_AB_BULLETIN_EXCEPTION">
                    <HeaderTemplate>
                        <div class="form-panel" style="font-size: small;">
                            <table class="notepad-table" cellpadding="2" cellspacing="0">
                                <thead>
                                    <tr style="background-color: #eeeeee; font-weight: bold;">
                                        <th>Date Time From</th>
                                        <th>Date Time To</th>
                                        <th>Status</th>
                                        <th>Last Modified</th>
                                        <th>Last Modified By</th>
                                        <th>Action</th>
                                    </tr>
                                </thead>
                                <tbody>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr id="tr1" runat="server">
                            <td>
                                <asp:Literal ID="Literal1" runat="server" Text='<%# Eval("EFTV_FROM") %>' />
                            </td>
                            <td>
                                <asp:Literal ID="Literal2" runat="server" Text='<%# Eval("EFTV_TO") %>' />
                            </td>
                            <td>
                                <asp:Literal ID="Literal3" runat="server" Text='<%# Eval("AB_STATUS1") %>' />
                            </td>
                            <td>
                                <asp:Literal ID="Literal4" runat="server" Text='<%# Eval("LAST_MOD_DATE") %>' />
                            </td>
                            <td>
                                <asp:Literal ID="Literal6" runat="server" Text='<%# Eval("UserName") %>' />
                            </td>
                            <td>
                                <asp:Button ID="editException" Text="Edit" runat="server" CommandName="EXID" CommandArgument='<%# Eval("EX_ID") %>' OnCommand="editException" />
                                <asp:Button ID="deleteException" Text="Delete" runat="server" CommandName="EXID" CommandArgument='<%# Eval("EX_ID") %>' OnCommand="deleteException" />
                            </td>

                        </tr>
                    </ItemTemplate>
                    <FooterTemplate>
                        </tbody>
                            </table> 
                            </div>
                    </FooterTemplate>
                </asp:Repeater>
            </div>

Output:

这篇关于修复ASP.NET中的转发器中的标题行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆