I am working on ASP.NET application which is using Entity Framework and getting data from a Database. I have following code to filter rendering data on a Grid View. I tried this code which it wrong for sure!
protected void btnSearch_Click(object sender, EventArgs e)
{
GISEntities gis = new GISEntities();
GIS_CONTRACTOR_TEST tbl = gis.GIS_CONTRACTOR_TEST.ToList().Where(x => x.CONTRACTORNAME == txtSearch.Text).First();
GridView1.DataSource = tbl.CONTRACTORNAME;
GridView1.DataBind();
}
As you can see I have problem on GridView1.DataSource = tbl.CONTRACTORNAME; which I couldn't find any other property for tbl except of field constructors. Can you please let me know how I can filter the database into a grid View instead of displaying them separately!
Thanks