GridView 的各种操作
在RowDataBound事件中加入如下代码
protected void gv_projectDocumentView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//鼠标经过时,行背景色变
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#00A9FF'");
//鼠标移出时,行背景色变
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
}
} {
if (e.Row.RowType == DataControlRowType.DataRow)
{
//鼠标经过时,行背景色变
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#00A9FF'");
//鼠标移出时,行背景色变
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
}
时间格式
<%#string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(Eval("useDateTime")))%>
关闭本页面
Response.Write("<script language:javascript>javascript:window.opener=null;window.close();</script>");
在删除之前弹出确认对话框
<asp:LinkButton runat="server" OnClientClick="return confirm('确认要借阅该文档吗?')" ID="lbOperator" CommandName="operator"> <%# Eval("status").ToString() == "True" ? "借出" : ""%></asp:LinkButton>