在ASP.NET中为GridView调整Div标签的大小 [英] Sizing a Div tag for a GridView in ASP.NET

查看:74
本文介绍了在ASP.NET中为GridView调整Div标签的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个使用GridViews显示和编辑数据的ASP.NET应用程序.

当我的GridView 足够大而需要水平滚动条时,我想要一个带有滚动条的Div 标记,该滚动条允许GridView 进行滚动,而其他所有内容仍可以显示在屏幕上,而不是滚动整个页面.

我可以使用max-width CSS属性来执行此操作,但这仅适用于一种尺寸.

我可以在javascript中设置一个事件来更改Div 标签的style属性,但是每次窗口大小更改时都需要更改它,而这在IE 9中是不会发生的.我也讨厌这样做.我想用一个不需要更改的CSS属性来控制它.

到目前为止,这是我用来为原型执行此操作的代码,但是我需要一种更好的方法来执行此操作.

I am writing an ASP.NET application which uses GridViews to display and edit data.

When my GridView is large enough to need a horizontal scroll bar, I want a Div tag with a scroll bar that allows the GridView to be scrolled while everything else still fits on the screen instead of scrolling the whole page.

I can do this with the max-width CSS property, but this only works for one size.

I can set an event in javascript to change the style property of the Div tag but then I need to change it everytime the window size changes, which isn''t happening in IE 9. I also hate doing it this way. I want to control it with one CSS property that doesn''t have to change.

This is the code I''ve used so far to do this for my prototype, but I need a better way to do this.

onresize = changewidth();

function changewidth() {
    document.getElementById("LowerPanel").setAttribute("style",
    "max-width: " + (document.body.offsetWidth - 10).toString() + "px;overflow-x:scroll;");
}




谢谢,
Bryan




Thanks,
Bryan

推荐答案

您可能想在这里查看操作方法: ^ ].
在此搜索中查看一些文章:
You may want to check out how it was done here: ASP.NET Splitter Bar - Resize panels, table cells, and controls[^].
Check out some of the articles in this search: asp.net splitter control[^]


它不是我一直在寻找的解决方案,但它比window onresize事件更好,因为它在调整大小时实际上会触发.

It''s not the solution I was looking for but it works better than the window onresize event because it actually fires when it resizes.

<body onresize="changewidth();">



Visual Studio认为这无效,但IE确实有效.



Visual Studio doesn''t think this is valid, but IE does.


这篇关于在ASP.NET中为GridView调整Div标签的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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