/// <summary> /// 当GridView1绑定完毕数据集后,可以通过RowDataBound事件给该GRIDVIEW中数据做切合实际的转换 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) //判断是否是DataRow,以防止鼠标经过Header也有效果 { // e.Row.Attributes.Add("onmouseover", "e=this.style.backgroundColor; this.style.backgroundColor='#F4F4F4'"); // e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=e"); string FROMUSER = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "FROMUSER")); //获取到列表中的每条记录的ID string ISREADS = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "ISREAD")); //是否已经阅读 string READTIMES = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "READTIME")); //阅读的时间 string FILEPATH = DataBinder.Eval(e.Row.DataItem, "FILEPATH").ToString(); string TITLE = DataBinder.Eval(e.Row.DataItem, "TITLES").ToString(); string titletem = commons.MakeStringLength(TITLE, 28); if (FILEPATH.Length > 0) { e.Row.Cells[1].Text = "<a href='" + FILEPATH + "' title='" + TITLE + "[点击下载附件]' target='_blank'>" + titletem + "</a>"; e.Row.Cells[3].Text = "<img src='/Admin/images/doctofrom/HAVE.gif'/>"; } else { e.Row.Cells[1].Text = "<a title='" + TITLE + "[无附件]' target='_blank'>" + titletem + "</a>"; e.Row.Cells[3].Text = "<img src='/Admin/images/doctofrom/HAVENO.gif'/>"; } } }