0

我正在一个名为 as 的表上实现全文搜索,该表tbljobs名为jobdescription. 在前端,我在描述中获得了 html 标签。我正在显示记录,GridViewGridview正在RowDataBound解码文本。我在Gridview'sRowDataBound事件中使用以下代码:

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;
         }
    }

但没有任何效果..!!

4

1 回答 1

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;         
   }     
}
于 2012-07-31T11:46:44.850 回答