Share

1.Take object of linq sql

sewakdbDataContext swdb = new sewakdbDataContext();

2.Create object of table

tblEvents tblevent = new tblEvents();

3.Create a function for grid

private void _LoadGrid() {

	var v = (from d in swdb.tblEvents where d.ARCHIVE_STATUS ==false select d).ToList();

	v = v.Where(d => d.EV_PURPOSE.StartsWith(txtdesc.Text == null ? string.Empty : txtdesc.Text)).ToList();

	v = v.Where(d => d.EV_TITLE.StartsWith(txttitle.Text == null ? string.Empty : txttitle.Text)).ToList();

	v = v.Where(d => d.EV_PLACE.StartsWith(txtPlace.Text == null ? string.Empty : txtPlace.Text)).ToList();

	if(txtFromDate.Text!=string.Empty)

	v = v.Where(d => d.EV_DATE_FROM==Convert.ToDateTime(txtFromDate.Text.Trim())).ToList();

	if (txtTo.Text != string.Empty)

	v = v.Where(d => d.EV_DATE_TO == Convert.ToDateTime(txtTo.Text.Trim())).ToList();

	v = v.Where(d => d.EV_HOSTED_BY.StartsWith(txtHostedBy.Text == null ? string.Empty : txtHostedBy.Text)).ToList();

	gvevents.DataSource = v;

	gvevents.DataBind();

}

you can use this function for search.


Share