关键字变色!
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这一字段! 我弄了半天了!