代码

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<style type="text/css">
.blk_02
{
margin-top: 0px;
text-align: center;
height: 263px;
width: 1810px;
}
.blk_02 .table_title table
{
border-left: 0px solid #b3d3ec;
border-top: 0px solid #b3d3ec;
background: #e0f0fd;
color: #5198cc;
width: 1927px;
}
.blk_02 .table_title table th
{
border-right: 0px solid #b3d3ec;
border-bottom: 0px solid #b3d3ec;
height: 20px;
font-weight: normal;
text-align: center;
}
.blk_02 .table_data
{
height: 129px;
overflow: auto;

width: 834px;
}
.blk_02 .table_data table
{
border-left: 0px solid #b3d3ec;
margin-left: 0px;
text-align: left;
}
.blk_02 .table_data table td
{
border-right: 0px solid #b3d3ec;
border-bottom: 0px solid #b3d3ec;
height: 24px;
font-weight: normal;
text-align: center;
}
.style1
{
width: 772px;
}
.style2
{
height: 21px;
}
#demo1
{
width: 834px;
text-align: left;
}
.style3
{
width: 274px;
}
.style4
{
width: 271px;
}
.style5
{
width: 278px;
}
.style6
{
width: 282px;
}
.style7
{
width: 270px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="blk_02" id="chg">
<div class="table_title" style="width: 1746px; text-align: center">

<table style="width:96%;">
<tr>
<td colspan="3" class="style2">
沪 指</td>
<td colspan="3" class="style2">
深 指</td>
</tr>
<tr>
<td colspan="3">
上证指数:<%=szzs %></td>
<td colspan="3">
深圳成指:<%=szcz %></td>
</tr>
<tr>
<td class="style4">
名 称</td>
<td class="style5">
开盘价</td>
<td class="style3">
收盘价</td>
<td class="style6">
名 称</td>
<td class="style7">
开盘价</td>
<td>
收盘价</td>
</tr>
</table>
</div>
<table>
<tr>
<td class="style1">
<div class="table_data" id="demo" style="overflow:hidden;scroll:no">
<div id="demo1">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Width="837px" ShowHeader="False" onrowdatabound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="s2" HeaderText="名称" >
<ItemStyle Width="33%" />
</asp:BoundField>
<asp:BoundField DataField="s4" HeaderText="开盘价" >
<ItemStyle Width="33%" />
</asp:BoundField>
<asp:BoundField DataField="s8" HeaderText="收盘价" >
<ItemStyle Width="33%" />
</asp:BoundField>
</Columns>
</asp:GridView>
</div>
</div>
</td>

<td>
<div class="table_data" id="demo3"
style="overflow:hidden;scroll:no; text-align: left;">
<div id="demo2" style="top: 0px; left: 0px; width: 835px; text-align: left;">
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
ShowHeader="False" Width="833px" onrowdatabound="GridView2_RowDataBound">
<Columns>
<asp:BoundField DataField="HQZQJC" HeaderText="名 称" >
<ItemStyle Width="33%" />
</asp:BoundField>
<asp:BoundField DataField="HQJRKP" HeaderText="开盘价" >
<ItemStyle Width="33%" />
</asp:BoundField>
<asp:BoundField DataField="HQZJCJ" HeaderText="收盘价">
<ItemStyle Width="33%" />
</asp:BoundField>
</Columns>
</asp:GridView>
</div>
</div>
</td>
</tr>
</table>
</div>

<script type="text/javascript">
var speed = 30
function Marquee() {
if (document.getElementById("demo").scrollTop >= document.getElementById("demo1").offsetHeight - document.getElementById("demo").offsetHeight)
{
document.getElementById("demo").scrollTop = 0;
}
else
{
document.getElementById("demo").scrollTop++
}
if (document.getElementById("demo3").scrollTop >= document.getElementById("demo2").offsetHeight - document.getElementById("demo3").offsetHeight) {
document.getElementById("demo3").scrollTop = 0;
}
else {
document.getElementById("demo3").scrollTop++
}
}
var MyMar = setInterval(Marquee, speed)
document.getElementById("demo").onmouseover = function() { clearInterval(MyMar) }
document.getElementById("demo").onmouseout = function() { MyMar = setInterval(Marquee, speed) }
</script>
</form>
</body>
</html>

代码

CS代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;
using System.Data.Odbc;

namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
public static System.Data.DataTable dt;
public static string szzs, szcz;

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
OdbcConnection odbccon = new OdbcConnection();
odbccon.ConnectionString ="dsn=dbflink1";
odbccon.Open();
string str = string.Format("select S2,S4,S8 from show2003");
OdbcDataAdapter odb = new OdbcDataAdapter(str, odbccon);
System.Data.DataSet ds = new DataSet();
odb.Fill(ds);
szzs =ds.Tables[0].Rows[1].ItemArray[2].ToString();
this.GridView1.DataSource = ds;
this.GridView1.DataBind();

string str1 = string.Format("select HQZQJC,HQJRKP,HQZJCJ from SJSHQ");
//string str1 = string.Format("select S2,S8 from show2003");
OdbcDataAdapter odb1 = new OdbcDataAdapter(str1, odbccon);
System.Data.DataSet ds1 = new DataSet();
odb1.Fill(ds1);
this.GridView2.DataSource = ds1;
this.GridView2.DataBind();

string str2 = string.Format("select ZSZJZS from SJSZS");
//string str1 = string.Format("select S2,S8 from show2003");
OdbcDataAdapter odb2 = new OdbcDataAdapter(str2, odbccon);
System.Data.DataSet ds2 = new DataSet();
odb1.Fill(ds2);
szcz = ds2.Tables[0].Rows[2].ItemArray[0].ToString();

odbccon.Close();
}
}

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Convert.ToSingle(e.Row.Cells[1].Text) < Convert.ToSingle(e.Row.Cells[2].Text))
{
e.Row.ForeColor = System.Drawing.Color.Red;
}
else
{
e.Row.ForeColor = System.Drawing.Color.Green;

}
if (Convert.ToSingle(e.Row.Cells[1].Text) == Convert.ToSingle(e.Row.Cells[2].Text))
{
e.Row.ForeColor = System.Drawing.Color.Yellow;
}
}
}

protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Convert.ToSingle(e.Row.Cells[1].Text.Length) < Convert.ToSingle(e.Row.Cells[2].Text.Length))
{
e.Row.ForeColor = System.Drawing.Color.Red;
}
else
{
e.Row.ForeColor = System.Drawing.Color.Green;

}
if (Convert.ToSingle(e.Row.Cells[1].Text.Length) == Convert.ToSingle(e.Row.Cells[2].Text.Length))
{
e.Row.ForeColor = System.Drawing.Color.Yellow;
}

}
}
}

}

转载于:https://www.cnblogs.com/zgz_dpl/archive/2010/11/13/1876685.html

滚动的gridview相关推荐

  1. flutter -------- GridView的使用

    使用GridView将widget放置为二维列表. GridView提供了两个预制list,或者您可以构建自定义网格.当GridView检测到其内容太长而不适合渲染框时,它会自动滚动. GridVie ...

  2. Android RecyclerView 基本使用

    Android RecyclerView 基本使用 概述 RecyclerView出现已经有一段时间了,相信大家肯定不陌生了,大家可以通过导入support-v7对其进行使用. 据官方的介绍,该控件用 ...

  3. Android开源项目分类汇总-转载

    太长了,还是转载吧... 今天在看博客的时候,无意中发现了@Trinea在GitHub上的一个项目Android开源项目分类汇总,由于类容太多了,我没有一个个完整地看完,但是里面介绍的开源项目都非常有 ...

  4. Android开源项目分类汇总[转]

    Android开源项目分类汇总 如果你也对开源实现库的实现原理感兴趣,欢迎 Star 和 Fork Android优秀开源项目实现原理解析 欢迎加入 QQ 交流群:383537512(入群理由需要填写 ...

  5. 使用photoview+viewpager实现图片缩放切换(类似微信朋友圈图片查看)

    首先看一下最终效果 经过分析可知,整个页面布局应该是一个Listview,它的每一个条目item中包含原型头像(采用CircleImageVIew)一个数目可变的GridView和其他,Gridvie ...

  6. Android RecyclerView (一) 使用完全解析

    转载请标明出处: http://blog.csdn.net/lmj623565791/article/details/45059587: 本文出自:[张鸿洋的博客] 概述 RecyclerView出现 ...

  7. github开源项目大集合(1)

    github开源项目大集合 目前包括: Android 开源项目第一篇--个性化控件(View)篇  包括ListView.ActionBar.Menu.ViewPager.Gallery.GridV ...

  8. 一个常用的Android工具库

    英文版Readme ZXUtils现在已开始逐步加入各种好看的第三方UI控件,全面跨入2.0.0版本. 为更好的使用工具库,仍然采用ZX开头的模式. 从这个版本起,ZXUtils会逐渐加入更多,更全, ...

  9. android 图片预览动画,Android图片上传实现预览效果

    首先具体分析一下,实现的功能,其中需求分析是必不可少的,需求.逻辑清除之后,再上手写代码,思路会很清晰. 1.多图上传首先得选择图片(这里项目需求是既可以拍照上传也可以从相册中选择) 2.拍照上传很简 ...

最新文章

  1. PCL_common模块api代码解析
  2. python画图代码彩虹-python绘制简单彩虹图
  3. bootstrap-select实现下拉框多选效果
  4. application.properties引用其他文件_金橙智能 | C语言头文件组织与包含原则,你知道吗?...
  5. js上传文件;input上传文件;
  6. 63. Unique Paths II and 64. Minimum Path Sum
  7. mysql2012更改表名_T-SQL入門攻略之13-修改数据表
  8. pandas 不要编号 加一行_文科生带你学Python|Pandas读取数据
  9. C# Zip解压缩,规避 [content_types].xml 文件
  10. yii 使用 有赞sdk_有赞 App 动态化配置中心实践
  11. 智能语音市场有多大? 阿里巴巴将如何破局后来者居上?
  12. 数据通路习题分析之二
  13. css行内样式的属性设置,css的外部样式的设置
  14. 微信公众号支付功能开发
  15. 业务需求分析师最重要的5项顶级技能
  16. mysql passwor authen_mysql5.7 的 user表的密码字段从 password 变成了 authentication_string
  17. 金蝶凭证序时簿在哪_金蝶KIS旗舰版外购入库单序时簿界面没有凭证的按钮
  18. java基础(一)基础认识、数据类型
  19. python播放mp3文件
  20. v-model原理总结

热门文章

  1. ddpush php,GitHub - brok1n/ddpushWebManager: DDPUSH 的web管理解决方案
  2. 李振杰:中科红旗的生与死
  3. 云计算基础技术及解决方案介绍 - ZCCT考试
  4. AdvanCell完成由晨兴创投领投的1,800万澳元B轮融资
  5. 苏轼写的是一首八句的七律,这首绝句应该是后人假冒苏轼的作品。
  6. docker部署zabbix_agent
  7. 再谈 RocketMQ broker busy(实战篇)
  8. 接吻时最不想遇见的10种情况
  9. 什么是中间件,中间件有什么作用
  10. geogebra动态数学软件,实用工具