{
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] |