How to Use a Basic Date Picker With GridView

Written by alexander gokhfeld
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Use a Basic Date Picker With GridView
GridView control can display a calendar date using the date picker. (Jupiterimages/ Images)

The GridView control of the Microsoft ASP.NET Framework can present calendar dates on Web pages using the table form. It lets programmers set up a date picker in a template column of the Gridview. You can enter a date into a text box or click on an icon that opens a pop-up calendar. You need to add Javascipt function in order to display the pop-up calendar. By binding the GridView control with your ASP.NET website, you can use basic data picker with GridView.

Skill level:

Other People Are Reading


  1. 1

    Click the "Start" button in Windows and select the "Visual Studio" application from the "All Programs" menu.

  2. 2

    Click "File" and "Open" to open the C++ program where you want to use date picker with GridView control.

  3. 3

    Add the following code after the "clientID" line:

    protected void gridview1_rowediting(object sender, gridviewediteventargs e)

        int p;
        p = e.neweditindex;
        p += 2;
        string clientid = "ctl00_contentplaceholder1_gridview1_ctl";
        string startdate;
        if (p <= 9)
            startdate = clientid + "0" + p.tostring() + "_txt_when";
            startdate = clientid +  p.tostring() + "_txt_when";
        string targetdate;
        if (p <= 9)
            targetdate = clientid + "0" + p.tostring() + "_txt_tdate";
            targetdate = clientid +  p.tostring() + "_txt_tdate";

    Date1.CalendarDateString = "03.14.2011";

    Date1.CalendarDate = DateTime.Now;

  4. 4

    Add the following line into the "<head>" section of your web page with the GridView control using Windows Notepad:

    <link href="cal/popcalendar.css" type="text/css" rel="stylesheet" />.

  5. 5

    Click "FIle" and "Save" to add the basic date picker with the GridView in your C++ program.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.