大家帮帮忙啊,大家帮帮忙啊,大家帮帮忙啊,谢谢

lurebjia1hao 2007-05-03 03:22:34
我想使搜索出来的关键字变色,不知道该怎么实现,我是这么写的,可是不行
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里输入的任一字符就匹配成功,请问该怎么实现呢?谢谢所有回答的朋友
...全文
191 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
amandag 2007-05-04
  • 打赏
  • 举报
回复
第二个问题应该和分词有关系,怕不是这么简单了
amandag 2007-05-04
  • 打赏
  • 举报
回复
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
Label label1;
string a = "But";
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
label1 = (Label)e.Item.FindControl("Label1");
label1.Text = label1.Text.Replace(a, "<font color='#ff7f50'>" + a + "</font>");
}
}
sbqcel 2007-05-04
  • 打赏
  • 举报
回复
下面那个好像要分词,麻烦啊
sbqcel 2007-05-04
  • 打赏
  • 举报
回复
lb.Text.Replace(a, "<font color='#ff7f50'>"+a+"</font>");
lb1.Text.Replace(a, "<font color='#ff7f50'> " + a + "</font>");

换为

lb.Text = lb.Text.Replace(a, "<font color='#ff7f50'>"+a+"</font>");
lb1.Text = lb1.Text.Replace(a, "<font color='#ff7f50'> " + a + "</font>");
lurebjia1hao 2007-05-04
  • 打赏
  • 举报
回复
难道是问错地方了?哎
lurebjia1hao 2007-05-04
  • 打赏
  • 举报
回复
谢谢
lurebjia1hao 2007-05-04
  • 打赏
  • 举报
回复
希望有人帮忙
kmiaoer 2007-05-04
  • 打赏
  • 举报
回复
友情UP~!
lurebjia1hao 2007-05-04
  • 打赏
  • 举报
回复
还是没人,哎
lurebjia1hao 2007-05-03
  • 打赏
  • 举报
回复
谢谢你,还是不行
forgot 2007-05-03
  • 打赏
  • 举报
回复
試一下: if((e.Item.Cells[3].Text)=="abc")
e.Item.BackColor=Color.Blue;

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧