Reputation: 253
I am using CKEditor to enter details (The details contains html elements ). after that the details will be bind into a grid. In this I want to show this details without html tags in tooltip.
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();
}
}
}
But its not working please help me. Example:
string str= " <h1><span style="font-family:courier new,courier,monospace"><strong>457457</strong> 544444444444457457457</span>";
The result in tooltip should be 457457544444444444457457457
Please Help. Regards jithesh
Upvotes: 2
Views: 526
Reputation: 253
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();
}
}
Upvotes: 2
Reputation: 4721
IF you want to show the details without HTML tags, you can simply use as shown below in the BoundField
of the gridview:
Here you go,
<asp:BoundField DataField="yourcolumnid" HeaderText="Column Text" ItemStyle-Width="30" HtmlEncode="false" />
Hope it helps
Upvotes: 0