Posted on 2009-08-06 23:48
YangBayker 阅读(63)
评论(1) 编辑 收藏
今天弄了一天,发现现在写代码越来越慢了。
弄了一天才弄了个模式窗口,现在来把代码备个份。
protected void gvCard_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
////GridViwe高亮显示
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
///得到删除按钮
LinkButton lb = e.Row.FindControl("lbtnDelet") as LinkButton;
///GridView的模版列中的修改按钮
LinkButton updatelb = e.Row.FindControl("lbtUpdate") as LinkButton;
///取到点击这一行的主键
Label lblcardid = e.Row.FindControl("lblCardId") as Label;
///在修改按钮上注册onclick事件,把主键传入模版列,并在子窗体关闭时刷新父窗体
///window.location.reload();刷新页面
updatelb.Attributes.Add("onclick", string.Format("window.showModalDialog('CardUpdate.aspx?cardid={0}','scroll=yes;resizable=yes;help=no;');window.location.reload();", lblcardid.Text));
////给删除按钮加确定删除事件
lb.Attributes.Add("onclick", "return confirm('确认删除吗?')");
}
}