posts - 134,  comments - 22,  trackbacks - 0

 

 1 //连接数据库,读取数据
 2 
 3 
 4 
 5 DataSet ds1 = ShowData(flag,3,sqlConn2);
 6    this.dgShow.DataSource = ds1;                    //dgShow为DataGrid实例。
 7    this.dgShow.DataBind();
 8 
 9    for(int i=0;i<dgShow.Items.Count;i++)   //给每一行都添加事件(添加到html中)
10    { 
11 
12 dgShow.Items[i].Attributes.Add("onclick","window.open('rghtDwnOvertimeContents.aspx?No=" + ds1.Tables[0].Rows[i][0].ToString() + "&Type=" + ds1.Tables[0].Rows[i][1].ToStri   ng() + "')");
13 
14 //追加单行点击事件,在新页打开新页,并传递相应的参数。(参数传递采用URL方法)。
15 
16 //dgShow.Items[i].Attributes.Add("onclick","window.location='rghtDwnOvertimeContents.aspx?ApplyID=" + ds1.Tables[0].Rows[i][0].ToString() + "&AppliationType=" + ds1.Tables[0].Rows[i][1].ToString() + "&EmployeeManagementID=" + EmployeeManagementID + "';");
17 
18 //在本业中打开新页。
19     
20 
21 dgShow.Items[i].Attributes.Add("style","cursor:hand");
22 
23 //设置鼠标移动到行时,鼠标以手的形式显示
24 
25 dgShow.Items[i].Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='#aaaaaa'");
26 
27 //设置鼠标经过时,所在行的背景色~
28 
29 //"currentcolor=this.style.backgroundColor;"保存现在的背景色,以便鼠标移动后恢复原色。
30 
31 //this.style.backgroundColor='#aaaaaa' 设置鼠标所在行的背景色
32     
33 
34 dgShow.Items[i].Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor");
35 
36 //鼠标移动后,恢复为原来的背景色。
37 
38 }
39 
posted on 2007-07-03 15:44 TRE-China R&D 阅读(600) 评论(0)  编辑 收藏 引用 所属分类: ASP.NETC#
只有注册用户登录后才能发表评论。