retrieving 'shown' month from calendar control

T

tfsmag

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 variables
that allows me to set the beginning date and end date of my range for
the query. This means when i click on July, the datagrid should
repopulate with all the invoices due in July. Here is the code I have
thus far in trying to get those values.

dim shownmonth as string = (need code to get shown month)
dim shownyear as string = (need code to get shown year)
dim beginrange as date = shownmonth & "/1/" & shownyear
Dim daysinmonth As Integer =
beginrange.DaysInMonth(shownyear,shownmonth)
Dim EndRange As Date = shownmonth & "/" & daysinmonth & "/" & shownyear

any help would be very appreciated!

Thanks,
Jeff
 
S

Shimon Sim

You just get one date from the range of the dates and use
date.ToString("MM") - for Month and date.ToString("yyyy") for year.

See if this helps
 
T

tfsmag

hmm won't that just retrieve today's month and year values?

i need to get the month and the year on the calendar that is shown, so
that if i click ahead to the next month on the calendar it will
repopulate the grid with that month's invoices.
 
T

tfsmag

hmmm i'm kind of a newbie at asp.net, but when i try to put that event
in, the only args i get are for previous month and next month...

how do i account for this month and load the datagrid... if i bind the
datagrid inside that event will it not bring up the current month as
default?
 
S

Shimon Sim

What you get there is NewDate - this is the date that you need to use to
determine the month that Calendar will display.

You can use this event to Bind your datagrid.
I don't know any details about how you bind your grid and to what but what
ever you do you need to pass NewDate.Month as parameter.

In any case you will need to try to see if it works for you.
Shimon.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top