473,395 Members | 1,658 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,395 software developers and data experts.

Datetime formating and paging

Hi
I'm trying to create a pager that allows you to show records by year and
month! I am getting close but would really appritiate some help!

Can someone please tell me how I convert the value of (i) into a date so that

l.Text shows the date as Feb or Mar etc etc

EG:
If i = 1
then I want it to equal "Jan"
or
If i = 2
then I want it to equal "Feb"

Likewise

l.commandArgument should equal a date that can be cross referenced from a
datetime column in a database!

I would really appritiate any help! Thanks...
<code>

Private Sub DGAnno_ItemCreated(ByVal sender As System.Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles DGAnno.ItemCreated
If e.Item.ItemType = ListItemType.Footer Then
e.Item.Cells.Clear()

Dim tc As New TableCell
tc.ColumnSpan = 3
e.Item.Cells.Add(tc)
Dim spacer As New LiteralControl
spacer.Text = " "
tc.Controls.Add(spacer)
'Adds year list to the footer of the DataGrid
Dim rightNow As DateTime = DateTime.Now
Dim s As Integer 'create a string
s = rightNow.ToString("yyyy")
Dim i As Integer
For i = 1 To Right(s, Len(s) - InStr(s, "0"))
Dim l As New LinkButton
Dim lc As New LiteralControl
lc.Text = " "
l.Text = "200" & (i)
l.CommandName = "iDate"
l.CommandArgument = "200" & (i)
tc.Controls.Add(l)
tc.Controls.Add(lc)
Next

e.Item.Cells.Add(tc)
spacer.Text = "&nbsp; "
tc.Controls.Add(spacer)
Dim lb As New LiteralControl
lb.Text = "<br>"
tc.Controls.Add(lb)
'Adds month list to the footer of the DataGrid
Dim month As DateTime = DateTime.Now
Dim m As Integer 'create a string
m = month.ToString("MM")
For i = 1 To m
Dim l As New LinkButton
Dim lc As New LiteralControl
lc.Text = " "
l.Text = (i)
l.CommandName = "imonth"
l.CommandArgument = (i)
tc.Controls.Add(l)
tc.Controls.Add(lc)
Next
End If
End Sub
Nov 19 '05 #1
2 1345
Look at the data structure called an Array. you create a 12 element string
array with the month number as an index, and the value the month's name.

-- bruce (sqlwork.com)
"Tim::.." <myatix_at_hotmail.com> wrote in message
news:63**********************************@microsof t.com...
Hi
I'm trying to create a pager that allows you to show records by year and
month! I am getting close but would really appritiate some help!

Can someone please tell me how I convert the value of (i) into a date so
that

l.Text shows the date as Feb or Mar etc etc

EG:
If i = 1
then I want it to equal "Jan"
or
If i = 2
then I want it to equal "Feb"

Likewise

l.commandArgument should equal a date that can be cross referenced from a
datetime column in a database!

I would really appritiate any help! Thanks...
<code>

Private Sub DGAnno_ItemCreated(ByVal sender As System.Object, ByVal e
As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DGAnno.ItemCreated
If e.Item.ItemType = ListItemType.Footer Then
e.Item.Cells.Clear()

Dim tc As New TableCell
tc.ColumnSpan = 3
e.Item.Cells.Add(tc)
Dim spacer As New LiteralControl
spacer.Text = " "
tc.Controls.Add(spacer)
'Adds year list to the footer of the DataGrid
Dim rightNow As DateTime = DateTime.Now
Dim s As Integer 'create a string
s = rightNow.ToString("yyyy")
Dim i As Integer
For i = 1 To Right(s, Len(s) - InStr(s, "0"))
Dim l As New LinkButton
Dim lc As New LiteralControl
lc.Text = " "
l.Text = "200" & (i)
l.CommandName = "iDate"
l.CommandArgument = "200" & (i)
tc.Controls.Add(l)
tc.Controls.Add(lc)
Next

e.Item.Cells.Add(tc)
spacer.Text = "&nbsp; "
tc.Controls.Add(spacer)
Dim lb As New LiteralControl
lb.Text = "<br>"
tc.Controls.Add(lb)
'Adds month list to the footer of the DataGrid
Dim month As DateTime = DateTime.Now
Dim m As Integer 'create a string
m = month.ToString("MM")
For i = 1 To m
Dim l As New LinkButton
Dim lc As New LiteralControl
lc.Text = " "
l.Text = (i)
l.CommandName = "imonth"
l.CommandArgument = (i)
tc.Controls.Add(l)
tc.Controls.Add(lc)
Next
End If
End Sub

Nov 19 '05 #2
From: "Bruce Barker" <br******************@safeco.com>
| Look at the data structure called an Array. you create a 12 element
string
| array with the month number as an index, and the value the month's name.

There already exists one of these:
DateTimeFomatInfo.InvariantInfo.AbbreviatedMonthNa mes has an array
containing "Jan", "Feb", etc. You may have to adjust for a zero-based vs.
one-based array.

Katy

Nov 19 '05 #3

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

Similar topics

4
by: Saso Zagoranski | last post by:
Hi! I have created an SqlCommand object and I have set some parameters to it... One of the parameters is of the DateTime type; here is the code: sqlCommand.Parameters.Value =...
2
by: Jeff Shantz | last post by:
Hello, I'm developing a large statistics application for a call center. It often needs to calculate time spanning over months. For example, an agent's total talk time within 30 days. Since an...
15
by: Fritz Switzer | last post by:
I'd like to have a string assigned the value of a DateTime.AddMinutes(amount) so that the string is formatted in "HH:MM" format. For example: DateTime.Now.AddMinutes(30) returns "00:30" ...
2
by: sudip | last post by:
I hav a log.txt file which contains following DateTime format > Fri May 06 18:05:54 GMT+05:30 2005 . so plzz help me how to accept this format & update in my DataBase, so that my webapplication...
1
by: Alpha | last post by:
When I select a datetime variable into a dataset does that stay a datetime column? I specified it to be so in the dataset but having problem formating it in the Crystal. Thanks, Alpha ...
2
by: Peter Kirk | last post by:
Hi there I would like some help with parsing date strings to DateTime structures. I can see that DateTime has Parse and ParseExact methods - but I am not sure what is best for me to use, and...
3
by: Tayo | last post by:
How do I format a datetime datfield to show only dates in a datagrid control
5
by: A.M | last post by:
Hi, I have a datetime value and want to format it to "June 1, 2006" shape. How can I do that? Thank you,
5
by: Jeff User | last post by:
Hi all The date values in my dropdown list appear as mm/dd/yyyy Specifically, the day always contains 2 digits. I need to set the selected index of the dropdown to the date that equals another...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.