关于使用msdn里边的类的方法属性继承问题 多给分

来源:百度知道 编辑:UC知道 时间:2024/05/13 10:08:47
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//高亮显示指定行
e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='#FFF000'");
e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;");
//设置审核状态,并且设置相应的颜色。
if (e.Row.Cells[5].Text == "False")
{
e.Row.Cells[5].Text =StringFormat.HighLight("未审核",true);
}
else
{
e.Row.Cells[5].Text = StringFormat.HighLight("已审核", false);
}
//多余字 使用...显示
e.Row.Cells[2].Text = StringFormat.Out(e.Row.Cells[2].Text, 18);

}

下边是问题
e.Row.Cell

我还也没发现 stirngformat 有个HighLight方法
我怀疑是自己定义的~
我知道 有好多人都是自己定义 Highlight方法
一般用于搜索的 高亮显示~
其实方法体里面就是用的Replace 替换的
里面把要显示的内容替换成高亮
当然要用 样式配合~
如果 stringformat里面有的话 不太现实 因为样式不灵活 还不一定好用·
所以我认为 90%是自己定义的~
//text是源文本 key是要高亮显示的文本 style里的样式就是定义的高亮样式 这里是显示成红色

public static String Highlight( String text, String key )
{
if( key == null || key.Trim() == String.Empty )
return text;

text = text.Replace(key, "<span style="color:red">"+key+"</span>");

return text;
}