标题:关键字变色!
只看楼主
tatawlb
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2008-7-1
 问题点数:0 回复次数:1 
关键字变色!
OleDbConnection adc = DB.CreateDb();
        adc.Open();
        OleDbCommand adccmd = new OleDbCommand("select * from shoplist where provins like '%" + this.TextBox1.Text + "%' or city like '%" + this.TextBox1.Text + "%' or linker like '%" + this.TextBox1.Text + "%' or phone like '%" + this.TextBox1.Text + "%' or faxmail like '%" + this.TextBox1.Text + "%' or address like '%" + this.TextBox1.Text + "%'", adc);
        OleDbDataAdapter oda1 = new OleDbDataAdapter();
        DataSet ds1 = new DataSet();
        int y = Convert.ToInt32(adccmd.ExecuteScalar());
        oda1.SelectCommand = adccmd;
        oda1.Fill(ds1);
        if (this.TextBox1.Text == "")
        {
            Response.Redirect("Default.aspx");
        }
        string tmp = this.TextBox1.Text;
        for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
        {
                for (int j = 0; j < ds1.Tables[0].Columns.Count; j++)
                {
                        ds1.Tables[0].Rows[i][j] = ds1.Tables[0].Rows[i][j].ToString().Replace(tmp, "<font color=red ><strong>" + tmp + "</strong></font>");
                }
        }
        this.GridView1.DataSource = ds1.Tables[0];        
        this.GridView1.DataBind();
        adc.Close();




这是一段用关键字查询后给关键字变色的代码!但是数据库中的ID是自动编号没办法变他一但输入的关键字跟ID有相同就提示错误。, !  
  那位大哥解决下!  让他变色时,不变ID这一字段!  我弄了半天了!
搜索更多相关主题的帖子: 关键字变色 for 关键字 变色 dataset 
2008-07-03 11:33
tatawlb
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2008-7-1
得分:0 
已解决!
已解决!
2008-07-03 13:29



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-222411-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.427034 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved