我正在使用CKEditor输入详细信息(详细信息包含html元素)。之后,将细节绑定到网格中。在此,我想显示在工具提示中没有html标记的详细信息。
protected void grdStepMain_RowDataBound(object sender, GridViewRowEventArgs e)
{
int i = 0;
if (e.Row.RowType == DataControlRowType.DataRow)
{
foreach (TableCell cell in e.Row.Cells)
{
i++;
string description = cell.Text;
if (cell.Text.Length > 8 && (i == 2))
cell.Text = cell.Text.Substring(0, 8) + "....";
string newdescription = Regex.Replace(description, @"<[^>]+>| ", "").Trim();
cell.ToolTip = Regex.Replace(newdescription, @"<[^>]+>| ", "").Trim();
}
}
}
但它不起作用,请帮助我。例子:
string str= " <h1><span style="font-family:courier new,courier,monospace"><strong>457457</strong> 544444444444457457457</span>";
The result in tooltip should be 457457544444444444457457457
请帮忙。关于吉特什
int i = 0;
string newdescription = "";
if (e.Row.RowType == DataControlRowType.DataRow)
{
foreach (TableCell cell in e.Row.Cells)
{
i++;
string description = cell.Text;
if (cell.Text.Length > 8 && (i == 2))
{
string a = Regex.Replace(description, @"<.+?>| ", "").Trim();
cell.Text = a.Substring(0, 8) + "....";
}
if (i == 2)
{
newdescription = Regex.Replace(description, @"<.+?>| ", "").Trim();
}
cell.ToolTip = Regex.Replace(newdescription, @"<.+?>| ", "").Trim();
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句