打印本文 打印本文 关闭窗口 关闭窗口
ASP.NET程序中常用代码汇总(三)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2939  更新时间:2009/4/23 10:48:30  文章录入:mintao  责任编辑:mintao

 e.Item.Attributes["onmouseout"] = "javascript:this.style.backgroundColor=’#a0d7c4’;"; 
 e.Item.Attributes["onmouseover"] = "javascript:this.style.backgroundColor=’#d9ece1’;cursor=’hand’;" ; 


  //添加一个编号列: 

DataTable dt= c.ExecuteRtnTableForAccess(sqltxt); //执行sql返回的DataTable 
DataColumn dc=dt.Columns.Add("number",System.Type.GetType("System.String")); 

for(int i=0;i<dt.Rows.Count;i++) 

 dt.Rows[i]["number"]=(i+1).ToString(); 


DataGrid1.DataSource=dt; 
DataGrid1.DataBind(); 

  //DataGrid1中添加一个CheckBox,页面中添加一个全选框 

private void CheckBox2_CheckedChanged(object sender, System.EventArgs e) 

 foreach(DataGridItem thisitem in DataGrid1.Items) 
 
  ((CheckBox)thisitem.Cells[0].Controls[1]).Checked=CheckBox2.Checked; 
 } 


 // 将当前页面中DataGrid1显示的数据全部删除 

foreach(DataGridItem thisitem in DataGrid1.Items) 

 if(((CheckBox)thisitem.Cells[0].Controls[1]).Checked) 
 
  string strloginid= DataGrid1.DataKeys[thisitem.ItemIndex].ToString(); 
  Del (strloginid); //删除函数 
 } 

上一页  [1] [2] [3] [4] 

打印本文 打印本文 关闭窗口 关闭窗口