protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView dataRowView = (DataRowView)e.Row.DataItem; string text = this.GridView1.DataKeys[e.Row.RowIndex].Values[0].ToString(); e.Row.Attributes["id"] = text; e.Row.Attributes["mark"] = dataRowView["mark"].ToString(); e.Row.Attributes["onclick"] = "clickRow(this);"; CheckBox checkBox = (CheckBox)e.Row.Cells[0].FindControl("chk"); checkBox.Attributes["class"] = "chk"; checkBox.Attributes["id"] = text; Label label = (Label)e.Row.Cells[0].FindControl("Label3"); label.Attributes["style"] = "display:none"; string text2 = ProjectSupervise.StripHTML(e.Row.Cells[5].Text); if (text2.Length > 22) { e.Row.Cells[5].Text = text2.Substring(0, 21) + "..."; } else { e.Row.Cells[5].Text = text2; } e.Row.Cells[5].ToolTip = text2; Label label2 = (Label)e.Row.Cells[2].FindControl("Label1"); label2.Attributes["onclick"] = string.Concat(new object[] { "OpType('SEE','", this.PrjCode, "','", text, "');" }); label2.Text = dataRowView["AffairTitle"].ToString(); if (ProjectSupervise._typeVal == "List") { e.Row.Cells[0].Text = ""; e.Row.Cells[0].Visible = false; return; } } else { if (e.Row.RowType == DataControlRowType.Header) { e.Row.Cells[3].Text = this.listTitleStr; if (ProjectSupervise._typeVal == "List") { e.Row.Cells[0].Text = ""; e.Row.Cells[0].Visible = false; } } } }
public static string StripHTML(string strHtml) { string[] array = new string[] { "<script[^>]*?>.*?</script>", "<(\\/\\s*)?!?((\\w+:)?\\w+)(\\w+(\\s*=?\\s*(([\"'])(file://[\"'tbnr]|[^/7])*?/7|/w+)|.{0})|/s)*?(///s*)?>", "([\\r\\n])[\\s]+", "&(quot|#34);", "&(amp|#38);", "&(lt|#60);", "&(gt|#62);", "&(nbsp|#160);", "&(iexcl|#161);", "&(cent|#162);", "&(pound|#163);", "&(copy|#169);", "&#(\\d+);", "-->", "<!--.*\\n" }; string[] array2 = new string[] { "", "", "", "\"", "&", "<", ">", " ", "¡", "¢", "£", "©", "", "\r\n", "" }; string arg_135_0 = array[0]; string text = strHtml; for (int i = 0; i < array.Length; i++) { Regex regex = new Regex(array[i], RegexOptions.IgnoreCase); text = regex.Replace(text, array2[i]); } text.Replace("<", ""); text.Replace(">", ""); text.Replace("\r\n", ""); return(ProjectSupervise.DelHTML(text)); }