Click here to Skip to main content
12,065,756 members (26,990 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
design as follows in data grid view;;
Date  Session      Column name  Column name Column name Column name Column name 
 
18 1    1
18 1    2
18 1    3
18 1    4
in run mode date inpicker format is date, month in data grid view.
month should be character as example jan

Code as follows;
            int iRow = 0;
            this.datagridView.RowCount = 24;
            for (int i = 0; i < 6; i++)
            {
                DateTime newDate = dt_startweek.Value.AddDays(i);
                for (int newIndex = 1; newIndex <= 4; newIndex++)
                {
                  
datagridView[0, iRow].Value = newDate.Day.ToString() +"" + newDate.Month.ToString();
                    datagridView[1,iRow].Value = newIndex.ToString();
                    iRow = iRow + 1;
                }
            }
for the month code in data grid view mention code as
datagridView[0, iRow].Value = newDate.Day.ToString() +"" + newDate.Month.ToString();
that month shluld be character as jan not '1' in number.

output as follows in run mode in data grid view
Date    Session      Column name  Column name Column name Column name Column name 
 
18 jan   1 
18 jan   2
18 jan   3
18 jan   4
Posted 10-Jan-13 1:38am
Edited 10-Jan-13 5:24am
v3
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

You can use the DateTime.ToString() with format to display your datetime.
datagridView[0, iRow].Value = newDate.ToString("dd MMMM");
this will output your date as eg: "10 January"
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web03 | 2.8.160207.1 | Last Updated 10 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100