2012-07-31 105 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