protected void Page_Load(object sender, EventArgs e)
{
string StartDate = Date3.Text;
string Enddate = Date4.Text;
ds = objBLL.GetUser(ItemType, ItemStatus);
dt = ds.Tables[0];
if (StartDate != null)
{
Filter records from datatable dt in such a way that
ParticipationStartDate > startDate");
}
if (Enddate != null)
{
Filter records from datatable dt in such a way that
ParticipationEndDate < EndDate
}
if(StartDate!=null && Enddate!= null)
{
i need to filter records from datatable such that
ParticipationStartDate > StartDate
and ParticipationEndDate < EndDate
}
}
GridView1.DataSource = dt; dt is the filtered datatable
GridView1.DataBind();
}
ParticipationStartDate,ParticipationEndDate is a column in the datatable.
startdate and enddate are textbox fields in the aspx.
So this is what I am trying to do.
If the startdate(date3.text) is not null, then datatable should give the records such that ParticipationStartDate > startdate
If the enddate(date4.text) is not null, then datatable should give the records such that ParticipationEndDate < enddate
You can use the DataTable.DefaultView capabilities to do filtering. Example:
Then:
Sample output:
Produces only 6 records on the filtered datatable: