473,386 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

calendar control : how to retrieve the "shown" month and year

i need to create a date range based on the current "shown" month on a
calendar control to query a database and populate a datagrid based on
that date range.

how can i retrieve the "shown" month and year from the calendar control
to create this range. Here is what i was thinking, all i need is the
"shown" month and year to complete.

-----------------------------------------------
Dim themonth as string = (need code to retreive "shown" month)
Dim theyear as string = (need code to retreive "shown" year)
Dim BeginRange as date
Dim EndRange as date
BeginRange = themonth & "/1/" & theyear
Dim daysinmonth As Integer = BeginRange.DaysInMonth(theyear, themonth)
EndRange = themonth & "/" & daysinmonth & "/" & theyear
-----------------------------------------------

any help would be greatly appreciated, and i'm sort of a .net newbie so
if you could provide code examples it would be nice :P

Nov 19 '05 #1
8 1878
Let me know if this code works:
Dim themonth As String = Me.Calendar1.VisibleDate.Month
Dim theyear As String = Me.Calendar1.VisibleDate.Year

"tfsmag" <tf****@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
i need to create a date range based on the current "shown" month on a
calendar control to query a database and populate a datagrid based on
that date range.

how can i retrieve the "shown" month and year from the calendar control
to create this range. Here is what i was thinking, all i need is the
"shown" month and year to complete.

-----------------------------------------------
Dim themonth as string = (need code to retreive "shown" month)
Dim theyear as string = (need code to retreive "shown" year)
Dim BeginRange as date
Dim EndRange as date
BeginRange = themonth & "/1/" & theyear
Dim daysinmonth As Integer = BeginRange.DaysInMonth(theyear, themonth)
EndRange = themonth & "/" & daysinmonth & "/" & theyear
-----------------------------------------------

any help would be greatly appreciated, and i'm sort of a .net newbie so
if you could provide code examples it would be nice :P

Nov 19 '05 #2
no, that set themonth to "1" and theyear to "2001"

Nov 19 '05 #3
i should also mention that i will need the variables to reflect the
"shown" date, so that means when it moves forward a month, beginrange
and endrange need to move forward a month.

Nov 19 '05 #4
What was the actual visible date?

"tfsmag" <tf****@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
no, that set themonth to "1" and theyear to "2001"

Nov 19 '05 #5
visible date was not set, if i set the visible date to date.now it
doesn't change with the month. is there a way to make visibledate
change when you click forward or backward a month?

Nov 19 '05 #6
Now I'm confused about what you're asking. If you don't set VisibleDate
anywhere, then it defaults to the current month until the user changes it.
VisibleDate should always be the same as what you are actually seeing.

Maybe you are putting your code in the wrong spot. I tried checking
VisibleDate from the Page_Load, but it wasn't set. Try putting your code
inside the VisibleMonthChanged method. Of course, someone will actually have
to change the month for this event to fire. But if the month hasn't been
changed or set, then you'll know what the values of BeginRange and EndRange
should be (the current month)

Private Sub Calendar1_VisibleMonthChanged(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.MonthChangedEventArgs) Handles
Calendar1.VisibleMonthChanged
Dim themonth As String = Me.Calendar1.VisibleDate.Month
Dim theyear As String = Me.Calendar1.VisibleDate.Year
Dim BeginRange As Date
Dim EndRange As Date
BeginRange = themonth & "/1/" & theyear
Dim daysinmonth As Integer = BeginRange.DaysInMonth(theyear, themonth)
EndRange = themonth & "/" & daysinmonth & "/" & theyear
End Sub

"tfsmag" <tf****@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
visible date was not set, if i set the visible date to date.now it
doesn't change with the month. is there a way to make visibledate
change when you click forward or backward a month?

Nov 19 '05 #7
that last post helped me figure it out, thanks!

Nov 19 '05 #8
Awesome!

"tfsmag" <tf****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
that last post helped me figure it out, thanks!

Nov 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Shuffs | last post by:
Could someone, anyone please tell me what I need to amend, to get this function to take Sunday as the first day of the week? I amended the Weekday parts to vbSunday (in my code, not the code...
7
by: Steve | last post by:
Can someone recommend a way to display a one-month calendar view where the month can be selected and up to six events can be shown in any day of the calendar. The events and dates would be stored...
1
by: Joseph Del Medico | last post by:
I'm trying to use a query whose SQL view is shown below to get a recordset of all first quarter records from a table for a year that is in the textbox of a form, so I can sum up the totals for the...
6
by: Alan Silver | last post by:
hello, If I capture the OnItemDataBound event for a repeater, datalist, etc, I can get hold of a control in the ItemTemplate like this ... Literal litFred =...
2
by: RJN | last post by:
Hi I have a calendar control and a dropdown in the page. Drop down has the list of all months. When the user either selects a date from a calendar or selects a month from the dropdown , I need...
7
by: tfsmag | last post by:
Okay, i have a datagrid that I want to populate with invoices that are due on the month shown on the calendar, so what i need to do is retrieve the current 'shown' month and create a couple of...
27
by: Dino M. Buljubasic | last post by:
I'd like to build a calendar displaying all days in a month in a grid so that when I click on the header of a square representing a day of month, I can add a new meeting etc. I know that .net...
5
by: Gary | last post by:
I am wondering if there is a control available in C# to display a downward triangle, and show the list box with roll up and roll down triangles if the files number is out of range?
22
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.