问题1:
如果改变某一列指定内容的字体颜色:
比如 列
if (string str == "未接收")
{
让这个单格元置为红色;
}问题2:
我用SQL模 糊查询关键字.
然后用GrivdView 显示
如何让查询的关键字在grivdView里显示高亮,像百度查询的那样.
只不过是放在GrivdView里.
高手帮忙.
如果改变某一列指定内容的字体颜色:
比如 列
if (string str == "未接收")
{
让这个单格元置为红色;
}问题2:
我用SQL模 糊查询关键字.
然后用GrivdView 显示
如何让查询的关键字在grivdView里显示高亮,像百度查询的那样.
只不过是放在GrivdView里.
高手帮忙.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string str = e.Row.Cells[0].Text;
//Cells[0]为第一列
if (str== "未接收")
{
e.Row.Cells[0].BackColor = System.Drawing.Color.Red;
}
//查找关键字
if (str.Contains("keyName"))
{
string newStr = "<font color=red>" + str + "</font>"; e.Row.Cells[0].Text = str.Replace("班keyName", newStr);
} }
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string str = e.Row.Cells[0].Text;
//Cells[0]为第一列
if (str== "未接收")
{
e.Row.Cells[0].BackColor = System.Drawing.Color.Red;
}
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string str = e.Row.Cells[0].Text;
//Cells[0]为第一列
if (str== "未接收")
{
e.Row.Cells[0].BackColor = System.Drawing.Color.Red;
}
//查找关键字
for(int i=0;i<列数;i++)
{
str = e.Row.Cells[i].Text;
if (str.Contains("keyName"))
{
string newStr = "<font color=red>" + str + "</font>"; e.Row.Cells[0].Text = str.Replace("班keyName", newStr);
}
}
}
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string str = e.Row.Cells[0].Text;
//Cells[0]为第一列
if (str== "未接收")
{
e.Row.Cells[0].BackColor = System.Drawing.Color.Red;
}
//查找关键字
for(int i=0;i <列数;i++)
{
str = e.Row.Cells[i].Text;
if (str.Contains("keyName"))
{
string newStr = " <font color=red> " + str + " </font> "; e.Row.Cells[i].Text = str.Replace("班keyName", newStr);
}
}
}
}
请参考影片:http://download.csdn.net/source/204062