62,046
社区成员
发帖
与我相关
我的任务
分享
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)//判定当前的行是否属于datarow类型的行
{
string strcut = e.Row.Cells[4].Text;
if(e.Row.Cells[4].Text.Length>31)
{
strcut = e.Row.Cells[4].Text.Substring(0, 31);
}
//using System.Text.RegularExpressions;
Regex reg = new Regex(@"(?is)(?<=<p>).*?(?=</p>)", RegexOptions.IgnoreCase);
string content = reg.Match(strcut).Value;
e.Row.Cells[4].Text = content;
}
}
//Regex reg = new Regex(@"(?is)(?<=<p>).*?(?=</p>)", RegexOptions.IgnoreCase);
string content =Regex.Replace(strcut, @"(?is)<p>|</p>",""); ;
if (e.Row.RowType == DataControlRowType.DataRow){....}
里面就无法替换,各种方法都试过了。