无法在ASP.Net 3.5中同时滚动2个网格

Unable to Scroll 2 Grids simultaneously in ASP.Net 3.5
2021-07-22
  •  译文(汉语)
  •  原文(英语)

我正在使用Visual Studio 2008(带有C#的ASP.Net 3.5)开发Web应用程序.我添加了两个System.Web.UI.WebControls.GridView类型的GridView.现在,我希望水平滚动GridView1时,GridView2也随之滚动.我尝试了许多解决方案,但是每当我尝试使用解决方案代码时,都会发生错误,"其中不包含Scroll / Horizo​​ntalScrollBar等的定义".甚至没有用于浏览的GridView事件也可以解决我的问题.

如果有人有解决方案,请告诉我.我将非常高兴,因为我试图从最近的2天开始解决此问题.

速聊1:
这超出了ASP.Net和C#的范围.必须使用JavaScript完成.你有多远?您的网格并排显示吗?您可以单独滚动它们吗?
速聊2:
在一个网页上,我有两个不同的网格,我想在用户滚动另一个网格时自动滚动其中一个.您说的是在纯C#中是不可能的,但是我看到了一些人们在使用C#命令的解决方案.但是这些命令在我的应用程序中不起作用.
速聊3:
如果页面的源代码中有解决方案,那么我也想知道.
速聊4:
将您的gridviewS放到iframe中,然后将水平滚动条放到iframe中.当您滚动到一侧时,您将同时滚动两个gridview.如果您不喜欢默认滚动条的外观,请使用css更改滚动条的样式
解决过程1

您可以将网格放在两个div中,left并使用right对其进行样式设置overflow:scroll;.

<div id="left">
    ...grid1 here
</div>

<div id="right">
    ...grid2 here
</div>

然后,您可以使用以下jQuery脚本来同步滚动事件:

$(window).load(function(){
    $('#right').on('scroll', function () {
        $('#left').scrollLeft($(this).scrollLeft());
    });
}); 

I am working on a web application using visual studio 2008 (ASP.Net 3.5 with C#). I have added two GridViews of System.Web.UI.WebControls.GridView type. Now I want that when I scroll the GridView1 horizontally, the GridView2 also scrolls along with it. I have tried many solutions but whenever I tried to use the solution code, error occurred that 'does not contain a definition for Scroll/HorizontalScrollBar etc'. Even there is no GridView event for scrolling through which I can solve my problem.

If anybody has the solution then please let me know. I will be very pleased because I am trying to solve this problem from last 2 days.

Talk1:
This is outside of the realm of ASP.Net and C#. It must be done with JavaScript. How far have you got? Do you have your grids displaying side by side? Are you able to scroll them individually?
Talk2:
On a single web page I have two distinct Grids and I want to scroll one of them automatically as the user scrolls the other one. you are saying that this is not possible in pure C#, but I saw some solutions in which people are using C# commands. But those commands are not working in my application.
Talk3:
If there is a solution in Source code of the page then I also want to know about it.
Talk4:
put your gridviewS in an iframe, and put a horizontal scrollbar to the iframe. when u scroll to a side, you scroll both of the gridview. if you dont like the look of the default scrollbar, change the style of the scroll bar with css
Solutions1

You can put your grids in two divs named left and right styling them with overflow:scroll;.

<div id="left">
    ...grid1 here
</div>

<div id="right">
    ...grid2 here
</div>

Then you can use the following jQuery script to synchronize scrolling events:

$(window).load(function(){
    $('#right').on('scroll', function () {
        $('#left').scrollLeft($(this).scrollLeft());
    });
}); 
转载于:https://stackoverflow.com/questions/17378359/unable-to-scroll-2-grids-simultaneously-in-asp-net-3-5

本人是.net程序员,因为英语不行,使用工具翻译,希望对有需要的人有所帮助
如果本文质量不好,还请谅解,毕竟这些操作还是比较费时的,英语较好的可以看原文

留言回复
我们只提供高质量资源,素材,源码,坚持 下了就能用 原则,让客户花了钱觉得值
上班时间 : 周一至周五9:00-17:30 期待您的加入