grid_ItemDataBound(object sender, DataGridItemEventArgs e)中:
... {
//当为1时,显示已审,当为0时,显示未审
foreach (DataGridItem a in grid.Items)
...{
if (a.Cells[11].Text.ToString().Trim() == "1")
...{
a.Cells[11].Text = "已审";
a.Cells[16].Enabled = false;//修改和删除不可用
a.Cells[17].Enabled = false;
}
if (a.Cells[11].Text.ToString().Trim() == "" || a.Cells[11].Text.ToString().Trim() == "0" || a.Cells[11].Text.ToString().Trim() == "NULL")
...{
a.Cells[15].Text = "未审";
}
}
当显示审核时,修改和删除不可用!!
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
...{
if (e.Item.Cells[15].Text.Trim() == "已审")
...{
foreach (HyperLink lb in e.Item.Cells[17].Controls)
...{
if (lb != null)
...{
lb.Enabled = false;
lb.Attributes["onClick"] = "";
}
}
foreach (HyperLink lb in e.Item.Cells[18].Controls)
...{
if (lb != null)
...{
lb.Enabled = false;
lb.Attributes["onClick"] = "";
}
}
}
}
//以下为样例,请参照使用
foreach (System.Web.UI.WebControls.HyperLink link in e.Item.Cells[18].Controls)
...{
link.Attributes.Add("onClick", "if (!window.confirm('您真的要删除这条记录吗?')){return false;}");
}
if (e.Item.ItemIndex >= 0)//设置表格中鼠标经过的色彩
...{
string title = "#FFFF00";
string bgcolor = "#FFFFFF";
e.Item.Attributes.Add("onMouseOver", "this.style.backgroundColor='" + title + "'; this.style.cursor='hand';");
e.Item.Attributes.Add("onMouseOut", "this.style.backgroundColor='" + bgcolor + "';");
}
}
grid_ItemCommand(object source, DataGridCommandEventArgs e)中:
... {
if (e.CommandName == "aa")
...{
if (e.Item.Cells[7].Text.Trim() != "" || e.Item.Cells[8].Text.Trim() != "")
...{
Response.Redirect("add/AddTheory.aspx");
Session["strWhere"] = ID;
}
else
...{
Response.Redirect("add/AddGrm.aspx");
}
}
}
//审核选定的记录
protected void Confirm_Click(object sender, EventArgs e)
{
string dgIDs = "";
bool BxsChkd = false;
foreach (DataGridItem item in grid.Items)
{
CheckBox ChkBxItem = (CheckBox)item.FindControl("UpdateThis");
if (ChkBxItem.Checked)
{
BxsChkd = true;
//注意必须正确指出ID列单元,是隐藏的,单引号和逗号必须要
dgIDs += "'" + item.Cells[0].Text + "',";
}
}
if (BxsChkd)
{
dgIDs = dgIDs.Substring(0, dgIDs.LastIndexOf(","));
//产生业务对象进行更新操作,审核和去审核的公用类
PFCMIS.BLL.CommonCheck bllcc = new PFCMIS.BLL.CommonCheck();
bllcc.CheckMark("CheckMark", "ID", "StuPracGrad", dgIDs);
Response.Redirect("Index.aspx");
}
}
//去掉审核选定的记录
protected void UnConfirm_Click(object sender, EventArgs e)
{
string dgIDs = "";
bool BxsChkd = false;
foreach (DataGridItem item in grid.Items)
{
CheckBox deleteChkBxItem = (CheckBox)item.FindControl("UpdateThis");
if (deleteChkBxItem.Checked)
{
BxsChkd = true;
//注意必须正确指出ID列单元,是隐藏的,单引号和逗号必须要
dgIDs += "'" + item.Cells[0].Text + "',";
}
}
if (BxsChkd)
{
dgIDs = dgIDs.Substring(0, dgIDs.LastIndexOf(","));
//产生业务对象进行更新操作,审核和去审核的公用类
PFCMIS.BLL.CommonCheck bllcc = new PFCMIS.BLL.CommonCheck();
bllcc.UnCheckMark("CheckMark", "ID", "StuPracGrad", dgIDs);
Response.Redirect("Index.aspx");
}
}