在datagrid中怎么实现里面的值中的关键字变色啊;或者是datatable中的值关键字变色。看到网上有这样:private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemIndex>-1)
{
string tmp = “关键字”;
foreach(TableCell cell in e.Item.Cells)
cell.Text = cell.Text.Replace(tmp,"<font color=red>"+tmp+"</font>");
}可是没法实现!郁闷啊!
{
if(e.Item.ItemIndex>-1)
{
string tmp = “关键字”;
foreach(TableCell cell in e.Item.Cells)
cell.Text = cell.Text.Replace(tmp,"<font color=red>"+tmp+"</font>");
}可是没法实现!郁闷啊!
public DataTable ChageTag(DataTable dt)
{
string tmp = tagname2; for(int i = 0;i<dt.Rows.Count;i++)
{
for(int j=0;j < dt.Columns.Count;j++)
{
dt.Rows[i][j]=dt.Rows[i][j].ToString().Replace(tmp,"<font color=red>"+tmp+"</font>");
}
}
原来这样就可以了。哈哈