如何在asp.net中滚动gridview行而不滚动标题名称?
我正在使用 asp.net2.0 ,在我的项目中使用一个 gridview ,其中 gridview 的行数在那里,所以我使用面板并在面板内部经过 gridview 并编写像
<asp:Panel ID="Panel1" runat="server" Height="100px" Width="550px" ScrollBars="Vertical" style="margin:0px 0 0 80px;" Visible="False">
<asp:GridView ID="grdCustomerInvoices" runat="server" AutoGenerateColumns="False" >
--
----
</asp:GridView>
</asp:Panel>
上面这样的代码,也滚动标题标题,但是我有标题名称是不变的(不滚动)并且行仅滚动。 请帮助我任何人
谢谢你 赫曼斯
i am using asp.net2.0 , in my project using one gridview in that gridview number of rows are there so i am using the panel and inside the panel past the gridview and write the code like this
<asp:Panel ID="Panel1" runat="server" Height="100px" Width="550px" ScrollBars="Vertical" style="margin:0px 0 0 80px;" Visible="False">
<asp:GridView ID="grdCustomerInvoices" runat="server" AutoGenerateColumns="False" >
--
----
</asp:GridView>
</asp:Panel>
above code scrolling the header titles also but i have header names are constant(not scrolling) and rows only scrolling .
pls help me any one
thank u
hemanth
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议您使用支持此功能的第三方控件。
要做到这一点并不容易。我几年前就这样做了,我没有示例代码。但在 item_databound 事件中,检查标题行是否已写入,并在创建第一个项目行之前插入一个 Div 标签,在创建最后一个项目行之后结束 Div 标签。根据您的喜好设置 div 的自动滚动和大小。
我过去曾这样做过并且有效。不幸的是我没有这方面的代码。
另一种方法是创建列标题的图像并将网格放置在其正下方。隐藏网格的标题行。但这不是一个可扩展的解决方案。
I would suggest you use third party control which supports this.
There is not easy way of doing this. I had doen this few years ago, I dont have sample code. But in item_databound event, check that the header row is written, and before the first item row is created insert a Div tag and after the last item row is created end the Div tag.set the autoscroll and size of the div as per your taste.
I have done this in past and it works. unfortunately I dont have code for this.
another way to do is create images of the column headers and place the grid right below it. hide the header row of the grid. but this is not a scalable solution.
如果您的要求仅此而已,则无需任何第三方控件。
第三方控件(例如“Telerik”的“RadGrid”)提供了各种其他功能,例如附加的客户端事件和其他设计优势。如果您的需求非常强烈,需要这些功能,那就去吧。
否则,如果您的要求只是静态标头,请参阅我在以下链接中发布的文章,
http://www.codeproject.com/Tips/602934/Static-Grid-Header
它仅使用 Css 即可完成任务。
No need for any Third party controls if your requirement is only this.
Third party controls like 'RadGrid' of 'Telerik' offer various other things like additional Client-Side events and other Design advantages. If your requirement is so intense that you need those features go for it.
Else if your requirement is only a Static Header, refer to the article that I have posted in the below link,
http://www.codeproject.com/Tips/602934/Static-Grid-Header
It accomplishes the task using only Css.
试试这个:
Try this: