Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have tow date picker as follows.


Datepicker1 DAtepicker2
when i choose datepicker1 8th day as monday in the datepicker 2 13th day saturday automically display in the datepicker2 no problem.

i want the output as

that 8th to 13th date will be diplayed in the row wise as follows.when i click the button.

what date i choose in the datepicker1 add 5 days and display that date to the datepicker2.when i click the load button that date to be displayed in the row wise in the date grid.
output as follows

DAte SS      GS     VR    CKK    CNN    RV   MS    TSS    CM

 8   1

 8   2

 8   3

 9   1

 9   2

 9   3

 10  1

 10  2

 10  3

 11  1

 11  2

 11  3

 12  1

 12  2

 12  3

 13  1

 13  2

 13  3


for that output how to write the code using csharp in windows application.

[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 6-Jan-13 2:28am
v2
Comments
Sandeep Mewara 6-Jan-13 8:21am    
OK, and where did you got stuck?
David_Wimbley 6-Jan-13 16:52pm    
Is this tied to a database? Need to know so can write query as well for this.

All you should need to do is create a method that loads the data grid, passes in the two dates and then your sql will have a BETWEEN clause that defines the Date between date picker 1 and date picker 2.

If you provide answer i can write snippet.

1 solution

You can try something like this. This is just a sample code for your thought you can modify this code based on your need.
C#
private void UpdateGrid(DateTime time, int noOfDays)
{
  for (int i = 1; i <= noOfDays; i++)
  {
     DateTime newDate = time.AddDays(i);

     for (int newIndex = 0; newIndex < 3; newIndex++)
     {
       DataGridViewRow row = new DataGridViewRow();

       row.Cells[0].Value = newDate.ToShortDateString();
       row.Cells[1].Value = newIndex;

       this.dataGridView1.Rows.Add(row);
                  
     }
   }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900