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 = " "
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