saparating Range of dates (urgent one pls)...
-
hi all, In my table i have two columns named FromDate and ToDate. I have to find the each and every date in that range and display them in a datagrid. Let us take from date: 06/10/2006 (mm/dd/yy) To Date: 06/15/2006 output should be like this( in datagrid) check box 06/10/2006 check box 06/11/2006 check box 06/12/2006 check box 06/13/2006 .... check box 06/15/2006 can anybody help me how to do it Thanx in advance.. your peter
-
hi all, In my table i have two columns named FromDate and ToDate. I have to find the each and every date in that range and display them in a datagrid. Let us take from date: 06/10/2006 (mm/dd/yy) To Date: 06/15/2006 output should be like this( in datagrid) check box 06/10/2006 check box 06/11/2006 check box 06/12/2006 check box 06/13/2006 .... check box 06/15/2006 can anybody help me how to do it Thanx in advance.. your peter
You simply read the from, to date values from the two columns in the table to the variables, then build a custom date list and bind it to the datagrid control. The sample code looks something like:
DateTime from = ...;
DateTime to = ...;List<DateTime> list = new List<DateTime>();
for(DateTime date = from; date < to; date=date.AddDays(1))
{
list.Add(date);
}gridDate.DataSource = list;
gridDate.DataBind();In case you use the ASP.NET 1.1, you can replace the generic List class with the ArrayList or a custom DateTime collection object.