GridView中加入DropDownList 纵向滚动后阻挡表头 为什么滚动GridView时 DropDownList阻挡住了表头有什么办法能不能滚动时 不阻挡表头谢谢各位了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <asp:Panel ID="Panel2" runat="server" Height="170px" HorizontalAlign="Left" Width="316px"> <yyc:GridView_ ID="GridView_1" runat="server" PageSize="5" MouseOverCssClass="OverRow" DataKeyNames="oid" Width="299px" BoundRowDoubleClickCommandName="DoubleClick" OnRowCommand="GridView_1_RowCommand" ContextMenuCssClass="RightMenu" AutoGenerateColumns="False" CellPadding="4" GridLines="None" Height="45px" onrowdatabound="GridView_1_RowDataBound" ForeColor="#333333" onpageindexchanging="GridView_1_PageIndexChanging"> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <Columns> <asp:TemplateField> <headertemplate> 序号 </headertemplate> <itemtemplate> <%# Container.DataItemIndex + 1 %> </itemtemplate> <ItemStyle Width="50px" /> </asp:TemplateField> <asp:TemplateField> <headertemplate> <asp:CheckBox ID="all2" runat="server" /> </headertemplate> <itemtemplate> <asp:CheckBox ID="item2" runat="server" /> </itemtemplate> <ItemStyle Width="50px" /> </asp:TemplateField> <asp:BoundField DataField="roomid" HeaderText="房号" SortExpression="roomid" /> <asp:BoundField DataField="specification" HeaderText="规格" SortExpression="specification" /> <asp:TemplateField HeaderText="类型"> <ItemTemplate> <asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList> </itemtemplate> <ItemStyle Width="50px" /> </asp:TemplateField> <asp:ButtonField CommandName="DoubleClick" Visible="false" /> <asp:ButtonField CommandName="RightMenuClick" Visible="false" /> </Columns> <SmartSorting AllowMultiSorting="True" AllowSortTip="True" /> <CascadeCheckboxes> <yyc:CascadeCheckbox ChildCheckboxID="item2" ParentCheckboxID="all2" /> </CascadeCheckboxes> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <FixRowColumn FixRowType="Header,Pager" FixRows="" FixColumns="0,1" /> <HeaderStyle Height="20px" BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#999999" /> <PagerStyle HorizontalAlign="Center" /> <CheckedRowCssClass CheckBoxID="item2" CssClass="SelectedRow" /> <ContextMenus> <yyc:ContextMenu Text="房间右键菜单" BoundCommandName="RightMenuClick" /> <yyc:ContextMenu Text="webabcd blog" NavigateUrl="http://webabcd.cnblogs.com" Target="_blank" /> </ContextMenus> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> <RowStyle Height="20px" /> </yyc:GridView_> 这是你自定义一个控件还是怎么回事,,怎么是前缀不是asp,是yyc。。 是自定义的。那asp的 不一样吗这只是继承了asp的那个 没改什么 <style>.Freezing{ position:relative ; table-layout:fixed; top:expression(this.offsetParent.scrollTop); z-index: 10;}.Freezing th{text-overflow:ellipsis;overflow:hidden;white-space: nowrap;padding:2px;}</style><div style="overflow-y: scroll; height: 200px;width:300px" id="dvBody"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="3" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" Font-Size="12px" Height="170px" Width="264px" > <FooterStyle BackColor="White" ForeColor="#000066" /> <Columns> <asp:TemplateField HeaderText="类型"> <ItemTemplate> <asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList> </itemtemplate> <HeaderStyle Width="50px" /> <ItemStyle Width="50px" /> </asp:TemplateField> </Columns> <RowStyle ForeColor="#000066" /> <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" CssClass="ms-formlabel DataGridFixedHeader"/> <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" CssClass="Freezing"/> </asp:GridView> </div>能有人告诉我 为什么纵向滚动条滚动的时候 DropDownList 会阻挡住表头吗?谢谢好心人 你这个用css做的,我不太清楚,,我这有个用javascript的,你看看能不能用。。<html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Gridview Header</title> <script language="javascript" type="text/javascript"> function init() { var bodyGridView=document.getElementById("<%=GridView1.ClientID%>"); var headGridView=bodyGridView.cloneNode(true); for(i=headGridView.rows.length-1;i>0;i--) headGridView.deleteRow(i); bodyGridView.deleteRow(0);//删掉数据行 headdiv.appendChild(headGridView);//删掉表头行 } window.onload=init; </script> <link href="~/CSS/Gridview.css" rel="stylesheet" type="text/css" /></head><body> <form id="form1" runat="server"> <div id="headdiv" style="top: 16px; text-align:center; left: 152px; position: absolute; width: 629px;height: 21px;word-wrap:break-word; overflow:hidden;"><!--不需要显示表头水平滚动条--> </div> <div id="bodydiv" style="top: 33px; left: 152px; position: absolute; width: 647px;height: 300px; overflow: auto" onscroll="headdiv.scrollLeft=scrollLeft"><!--表体的水平滚动条拖动触发表头的水平滚动事件--> <!--Gridview中必须定义表头和表体相同的宽度--> <asp:GridView ID="GridView1" BorderColor="Black" OnRowDataBound="GridView1_RowDataBound" runat="server" AutoGenerateColumns="False" Font-Size="12px" width="629px"> <Columns> <asp:BoundField DataField="ID" HeaderText="编号" > <HeaderStyle Width="40px" /> <ItemStyle Width="40px" /> </asp:BoundField> <asp:BoundField DataField="EmpID" HeaderText="账号" > <HeaderStyle Width="70px" /> <ItemStyle Width="70px" /> </asp:BoundField> <asp:BoundField DataField="EmpRealName" HeaderText="姓名" > <HeaderStyle Width="60px" /> <ItemStyle Width="60px" /> </asp:BoundField> <asp:TemplateField HeaderText="性别"> <ItemTemplate> <asp:DropDownList id="drpSex" runat="server"> <asp:ListItem Text="男" Value="1"/> <asp:ListItem Text="女" Value="0"/> </asp:DropDownList> </ItemTemplate> </asp:TemplateField> dropdownlist的特性就是这样。。动态隐藏掉吧 网站发布后出现这样的问题。 asp.net和jsp,学哪个比较多,哪个比较好 aspx和iframe的问题 SQL查询语句小问题 求Internet上访问在IIS里建好的网站 問一個關於日期查詢的問題~~~ 在DATAGRID绑定数据的时候,如果个列的数据满足一个条件的话,将这一行的背景色改为红色!应该怎么实现? 大家看一下这个错误出在那里,好郁闷! 一个vs10的状态栏显示的问题 我引用了一个第三方控件Interop.NATUPNPLib.dll,在IIS上发布报错 如何播放视频 asp.net 焦点控制问题
Width="316px">
<yyc:GridView_ ID="GridView_1" runat="server" PageSize="5" MouseOverCssClass="OverRow"
DataKeyNames="oid" Width="299px" BoundRowDoubleClickCommandName="DoubleClick"
OnRowCommand="GridView_1_RowCommand" ContextMenuCssClass="RightMenu"
AutoGenerateColumns="False" CellPadding="4"
GridLines="None" Height="45px"
onrowdatabound="GridView_1_RowDataBound" ForeColor="#333333"
onpageindexchanging="GridView_1_PageIndexChanging">
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<Columns>
<asp:TemplateField>
<headertemplate>
序号
</headertemplate>
<itemtemplate>
<%# Container.DataItemIndex + 1 %>
</itemtemplate>
<ItemStyle Width="50px" />
</asp:TemplateField>
<asp:TemplateField>
<headertemplate>
<asp:CheckBox ID="all2" runat="server" />
</headertemplate>
<itemtemplate>
<asp:CheckBox ID="item2" runat="server" />
</itemtemplate>
<ItemStyle Width="50px" />
</asp:TemplateField>
<asp:BoundField DataField="roomid" HeaderText="房号" SortExpression="roomid" />
<asp:BoundField DataField="specification" HeaderText="规格" SortExpression="specification" />
<asp:TemplateField HeaderText="类型">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>
</itemtemplate>
<ItemStyle Width="50px" />
</asp:TemplateField> <asp:ButtonField CommandName="DoubleClick" Visible="false" />
<asp:ButtonField CommandName="RightMenuClick" Visible="false" />
</Columns>
<SmartSorting AllowMultiSorting="True" AllowSortTip="True" />
<CascadeCheckboxes>
<yyc:CascadeCheckbox ChildCheckboxID="item2" ParentCheckboxID="all2" />
</CascadeCheckboxes>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<FixRowColumn FixRowType="Header,Pager" FixRows="" FixColumns="0,1" />
<HeaderStyle
Height="20px" BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<PagerStyle HorizontalAlign="Center" />
<CheckedRowCssClass CheckBoxID="item2" CssClass="SelectedRow" />
<ContextMenus>
<yyc:ContextMenu Text="房间右键菜单" BoundCommandName="RightMenuClick" />
<yyc:ContextMenu Text="webabcd blog" NavigateUrl="http://webabcd.cnblogs.com" Target="_blank" />
</ContextMenus>
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<RowStyle Height="20px" />
</yyc:GridView_>
那asp的 不一样吗
这只是继承了asp的那个 没改什么
.Freezing
{
position:relative ;
table-layout:fixed;
top:expression(this.offsetParent.scrollTop);
z-index: 10;
}.Freezing th{text-overflow:ellipsis;overflow:hidden;white-space: nowrap;padding:2px;}
</style>
<div style="overflow-y: scroll; height: 200px;width:300px" id="dvBody">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
CellPadding="3" BackColor="White"
BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" Font-Size="12px"
Height="170px" Width="264px" >
<FooterStyle BackColor="White" ForeColor="#000066" />
<Columns>
<asp:TemplateField HeaderText="类型">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>
</itemtemplate>
<HeaderStyle Width="50px" />
<ItemStyle Width="50px" />
</asp:TemplateField>
</Columns>
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" CssClass="ms-formlabel DataGridFixedHeader"/>
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" CssClass="Freezing"/>
</asp:GridView>
</div>
能有人告诉我 为什么纵向滚动条滚动的时候 DropDownList 会阻挡住表头吗?谢谢好心人
<head runat="server">
<title>Gridview Header</title>
<script language="javascript" type="text/javascript">
function init()
{
var bodyGridView=document.getElementById("<%=GridView1.ClientID%>");
var headGridView=bodyGridView.cloneNode(true);
for(i=headGridView.rows.length-1;i>0;i--)
headGridView.deleteRow(i);
bodyGridView.deleteRow(0);//删掉数据行
headdiv.appendChild(headGridView);//删掉表头行
}
window.onload=init;
</script>
<link href="~/CSS/Gridview.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div id="headdiv" style="top: 16px; text-align:center; left: 152px; position: absolute; width: 629px;height: 21px;word-wrap:break-word; overflow:hidden;"><!--不需要显示表头水平滚动条-->
</div>
<div id="bodydiv" style="top: 33px; left: 152px; position: absolute; width: 647px;height: 300px; overflow: auto" onscroll="headdiv.scrollLeft=scrollLeft"><!--表体的水平滚动条拖动触发表头的水平滚动事件-->
<!--Gridview中必须定义表头和表体相同的宽度-->
<asp:GridView ID="GridView1" BorderColor="Black" OnRowDataBound="GridView1_RowDataBound" runat="server" AutoGenerateColumns="False" Font-Size="12px" width="629px">
<Columns>
<asp:BoundField DataField="ID" HeaderText="编号" >
<HeaderStyle Width="40px" />
<ItemStyle Width="40px" />
</asp:BoundField>
<asp:BoundField DataField="EmpID" HeaderText="账号" >
<HeaderStyle Width="70px" />
<ItemStyle Width="70px" />
</asp:BoundField>
<asp:BoundField DataField="EmpRealName" HeaderText="姓名" >
<HeaderStyle Width="60px" />
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:TemplateField HeaderText="性别">
<ItemTemplate>
<asp:DropDownList id="drpSex" runat="server">
<asp:ListItem Text="男" Value="1"/>
<asp:ListItem Text="女" Value="0"/>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>