2012-07-31 131 views
0

我在名为jobdescription的图表上名为tbljobs的表上实施全文搜索。在前端,我在描述中获得了html标签。我正在显示GridViewGridview的记录RowDataBound我正在解码文本。我使用下面的代码放在GridviewRowDataBound事件:内容中的HTML标记

protected void GridNewlyPostedJobs_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
if (e.Row.RowType == DataControlRowType.DataRow) 
{ 
string decodedText =  HttpUtility.HtmlDecode(((Label)e.Row.FindControl("lblJobDescription")).Text); 
      ((Label)e.Row.FindControl("lblJobDescription")).Text = decodedText; 
     } 
    } 

但没有任何工程.. !!

回答

0

使用DataRowView获取数据...

protected void GridNewlyPostedJobs_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    DataRowView rowView = (DataRowView)e.Row.DataItem; 
    if (e.Row.RowType == DataControlRowType.DataRow) 
    { 
    string decodedText = HttpUtility.HtmlDecode(rowView["jobdescription"]);    
    ((Label)e.Row.FindControl("lblJobDescription")).Text = decodedText;   
    }  
} 
+0

谢谢您的回答......但遗憾地说,我媒体链接这样做,却忘了张贴。 – Agyapal 2012-07-31 13:34:17

+0

好的...你有答案吗? – 2012-08-01 07:26:13