using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
public CARDataContext context=new CARDataContext();
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
Repeater1.DataSource = context.Car;
Repeater1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string name = TextBox1.Text;
if (name != "")
{
var query = context.Car.Where(p=>p.Name.Contains(name));
foreach( Car data in query)
{
//data.Name = data.Name.Replace(name, "<mark>" + name + "</mark>");
data.Name = data.Name.Replace(name, "<span style=‘color:red‘>" + name + "</span>");
}
Repeater1.DataSource = query;
Repeater1.DataBind();
}
else
{
Repeater1.DataSource = context.Car;
Repeater1.DataBind();
}
}
}