当我向listview添加新行到达某个高度200px之后,它将滚动,而滚动标题也在滚动。如何修复此标题应该是常量
<asp:ListView ID="listview1" runat="server">
<LayoutTemplate>
<table runat="server" cellpadding="1" border="1" style="background-color: #FFFFFF;
border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
<tr style="background-color: #E5E5FE">
<th>
Order
</th>
<th>
Column Title
</th>
<th>
DataType
</th>
<th>
Exapmles
</th>
<th>
Options
</th>
<th>
Delete
</th>
</tr>
<tr id="itemplaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label ID="txtorder" Text='<%#Eval("OrderNo") %>' runat="server"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtcolumnname" Text='<%#Eval("ColumnTitle") %>' runat="server" Width="150"></asp:TextBox>
</td>
<td>
<asp:DropDownList ID="ddldatatype" runat="server" Width="160" >
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="ddlexamples" runat="server" Width="160">
<asp:ListItem Text="test" Value="2"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="txtoptions" Text='<%#Eval("Options") %>' runat="server" Width="150" ></asp:TextBox>
</td>
<td>
<asp:CheckBox ID="chkdel" runat="server" />
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background-color: #EFEFEF">
<td>
<asp:Label ID="txtorder" Text='<%#Eval("OrderNo") %>' runat="server"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtcolumnname" Text='<%#Eval("ColumnTitle") %>' runat="server" Width="150"></asp:TextBox>
</td>
<td>
<asp:DropDownList ID="ddldatatype" runat="server" Width="160" >
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="ddlexamples" runat="server" Width="160">
<asp:ListItem Text="test" Value="2"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="txtoptions" Text='<%#Eval("Options") %>' runat="server" Width="150"></asp:TextBox>
</td>
<td>
<asp:CheckBox ID="chkdel" runat="server" />
</td>
</tr>
</AlternatingItemTemplate>
</asp:ListView>
</div>
<br />
<br />
<asp:Button ID="btnAdd" runat="server" Text="Add New Row" OnClick="btnAdd_Click" />
   
<asp:Button ID="btndelete" runat="server" Text="Delete" onclick="btndelete_Click" />
</td>
</tr>
</table>
答案 0 :(得分:2)
您可以尝试将标题与内容分开,并将标题放在可滚动内容之外。
<div>Some Page Content </div>
//your heading goes here
<div style="max-height: 200px; overflow: auto;">
//your listview goes here
</div>
<div>Some Page Content </div>
像这样
<div style="float:left; width:100%;" >
<table id="Table1" runat="server" cellpadding="1" border="1" style="background-color: #FFFFFF;
border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px;width:100%;">
<tr style="background-color: #E5E5FE">
<th style="width:15%;">
Order
</th>
<th style="width:15%;">
Column Title
</th>
<th style="width:15%;">
DataType
</th>
<th style="width:15%;">
Exapmles
</th>
<th style="width:15%;">
Options
</th>
<th style="width:25%;">
Delete
</th>
</tr>
</table>
</div>
<div style="max-height: 200px; overflow: auto; float:left; width:100%;">
<asp:ListView ID="listview1" runat="server">
<LayoutTemplate>
<table id="Table1" runat="server" cellpadding="1" border="1" style="background-color: #FFFFFF;
border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px;
">
<tr style="background-color: #E5E5FE;display:none;">
<th>
Order
</th>
<th>
Column Title
</th>
<th>
DataType
</th>
<th>
Exapmles
</th>
<th>
Options
</th>
<th>
Delete
</th>
</tr>
<tr id="itemplaceholder" runat="server">
</tr>
</table>
</div>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td style="width:15%;">
<asp:Label ID="txtorder" Text='<%#Eval("OrderNo") %>' runat="server"></asp:Label>
</td>
<td style="width:15%;">
<asp:TextBox ID="txtcolumnname" Text='<%#Eval("ColumnTitle") %>' runat="server" Width="150"></asp:TextBox>
</td>
<td style="width:15%;">
<asp:DropDownList ID="ddldatatype" runat="server" Width="160">
</asp:DropDownList>
</td>
<td style="width:15%;">
<asp:DropDownList ID="ddlexamples" runat="server" Width="160">
<asp:ListItem Text="test" Value="2"></asp:ListItem>
</asp:DropDownList>
</td>
<td style="width:15%;">
<asp:TextBox ID="txtoptions" Text='<%#Eval("Options") %>' runat="server" Width="150"></asp:TextBox>
</td>
<td style="width:25%;">
<asp:CheckBox ID="chkdel" runat="server" />
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background-color: #EFEFEF">
<td>
<asp:Label ID="txtorder" Text='<%#Eval("OrderNo") %>' runat="server"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtcolumnname" Text='<%#Eval("ColumnTitle") %>' runat="server" Width="150"></asp:TextBox>
</td>
<td>
<asp:DropDownList ID="ddldatatype" runat="server" Width="160">
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="ddlexamples" runat="server" Width="160">
<asp:ListItem Text="test" Value="2"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="txtoptions" Text='<%#Eval("Options") %>' runat="server" Width="150"></asp:TextBox>
</td>
<td>
<asp:CheckBox ID="chkdel" runat="server" />
</td>
</tr>
</AlternatingItemTemplate>
</asp:ListView>
</div>