Click here to Skip to main content
15,075,944 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have need to create calendar control in which,
there are two drop downs of Month and year
When we select values in Month and Year dropdownlist, according dates of that month should be displayed in below table and allow user to select those dates.
Please help me to do this.
thank you.
Posted
Comments
Kornfeld Eliyahu Peter 8-Dec-14 4:55am
   
http://mattgemmell.com/what-have-you-tried/
(By the way, there is one - http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.calendar%28v=vs.110%29.aspx)
rahulDer 8-Dec-14 5:03am
   
Thank you but there is need not to use inbuilt controls but have to create custom controls.
Kornfeld Eliyahu Peter 8-Dec-14 5:08am
   
Great! Start with it and come back if you have any specific (code-related) question...

1 solution

manage to reach upto this but now i want to highlight Current date .
and want to add linkbutton nstead of just text in gridview rows.
Plz do suggest,here is my code:
I have button which generate grid with calender format

protected void Button1_Click(object sender, EventArgs e)
    {
        string month = ddlMonth.SelectedItem.Text;//txtMonth.Text;// should be in the format of Jan, Feb, Mar, Apr, etc...
        int yearofMonth = Convert.ToInt32(txtYear.Text);
        DateTime dateTime = Convert.ToDateTime("01-" + month + "-" + yearofMonth);
        DataRow dr;
        DataTable dt = new DataTable();
        dt.Columns.Add("Monday");
        dt.Columns.Add("Tuesday");
        dt.Columns.Add("Wednesday");
        dt.Columns.Add("Thursday");
        dt.Columns.Add("Friday");
        dt.Columns.Add("Saturday");
        dt.Columns.Add("Sunday");
        dr = dt.NewRow();
        for (int i = 0; i < DateTime.DaysInMonth(dateTime.Year, dateTime.Month); i += 1)
        {
            int count = 0;
            //txtMonth.Text = Convert.ToDateTime(dateTime.AddDays(0)).ToString("dddd");
            if (Convert.ToDateTime(dateTime.AddDays(i)).ToString("dddd") == "Monday")
            {
                LinkButton lnk = new LinkButton();
                lnk.Text = (i + 1).ToString();
                dr["Monday"] = i + 1;
                //GridView1.Rows[count].Cells[0].Controls.Add(lnk);
            }
            if (dateTime.AddDays(i).ToString("dddd") == "Tuesday")
            {
                dr["Tuesday"] = i + 1;
            }
            if (dateTime.AddDays(i).ToString("dddd") == "Wednesday")
            {
                dr["Wednesday"] = i + 1;
            }
            if (dateTime.AddDays(i).ToString("dddd") == "Thursday")
            {
                dr["Thursday"] = i + 1;
            }
            if (dateTime.AddDays(i).ToString("dddd") == "Friday")
            {
                dr["Friday"] = i + 1;
            }
            if (dateTime.AddDays(i).ToString("dddd") == "Saturday")
            {
                dr["Saturday"] = i + 1;
            }
            if (dateTime.AddDays(i).ToString("dddd") == "Sunday")
            {
                dr["Sunday"] = i + 1;
                dt.Rows.Add(dr);
                dr = dt.NewRow();
                count = count + 1;
                continue;
            }
            if (i == DateTime.DaysInMonth(dateTime.Year, dateTime.Month) - 1)
                {
                dt.Rows.Add(dr);
                dr = dt.NewRow();
                count = count + 1;
            }
        }
        GridView1.DataSource = dt;
        GridView1.DataBind();
    }
   

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