大家帮帮忙啊,大家帮帮忙啊,大家帮帮忙啊,谢谢
我想使搜索出来的关键字变色,不知道该怎么实现,我是这么写的,可是不行
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
Label lb = (Label)e.Item.FindControl("goodsnameLabel");
Label lb1=(Label)e.Item.FindControl("goodspriceLabel");
string a = Session["textbox"].ToString();//这是另一页TextBox里记录下的关键字
lb.Text.Replace(a, "<font color='#ff7f50'>"+a+"</font>");
lb1.Text.Replace(a, "<font color='#ff7f50'> " + a + "</font>");
}
这样也不行:
lb.Text.Replace("a", "<font color='#ff7f50'>a</font>");
lb1.Text.Replace("a", "<font color='#ff7f50'> a </font>");
请问该怎么办呢?是不是不能写在ItemDataBound里还是语法错误
还有问一下,在查询时,我想让TextBox里输入的字符,有任意一个字符在数据库里存在就行,
string sql = "select * from goods where goodsvar like '%" + a + "%' or goodsname like '%" + a+ "%'"; 这样写的话是数据库里的东西包含TextBox里输入的所有字符才成功,我想实现包含TextBox里输入的任一字符就匹配成功,请问该怎么实现呢?谢谢所有回答的朋友