Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 26th, 2008, 11:51 AM
Authorized User
 
Join Date: Jan 2008
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default Array

Hi
I am using a repeator control that loads Months from an array LOADMONTH(). What i am trying to do is to get the Month number as well so that with January it will return 1 and so on...


Thanks


*********************************************
<td>
        <asp:Repeater ID="RPTMonth" runat ="server" >
        <ItemTemplate>
            <% Dim NCategory As String = Request.QueryString("Category")
                Dim NYear As String = Request.QueryString("Year")

                %>


        <a href ='http://localhost/Bounty_NewsArchive/default.aspx?Category=<%=NCategory%>&Month=<%=NMon th%>&Year=<%#Container.DataItem%>'><%#Container.Da taItem%> - <%=NYear%> - <%=NCategory%></a>

        </ItemTemplate>
           <SeparatorTemplate ><br /></SeparatorTemplate>

        </asp:Repeater>

    </td>


    <td>
    <asp:Repeater ID="RPTYear" runat="server">
          <ItemTemplate>
          <%
                 Dim Ncategory As String = Request.QueryString("Category")
                 Dim NMonth As String = Request.QueryString("Month")
          %>

        <a href ='http://localhost/Bounty_NewsArchive/default.aspx?Category=<%=NCategory%>&Month=0&Year= <%#Container.DataItem%>'><%#Container.DataItem%> News Archive</a>

         </ItemTemplate>
         <SeparatorTemplate ><br /></SeparatorTemplate>
    </asp:Repeater></td>

*******************************************
 Public Function LoadMonths() As Array
        Dim Month(11) As String
        Month(0) = "January"
        Month(1) = "February"
        Month(2) = "March"
        Month(3) = "April"
        Month(4) = "May"
        Month(5) = "June"
        Month(6) = "July"
        Month(7) = "August"
        Month(8) = "September"
        Month(9) = "October"
        Month(10) = "November"
        Month(11) = "December"

        Return Month
    End Function
 
Old March 27th, 2008, 03:52 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 143
Thanks: 0
Thanked 1 Time in 1 Post
Default

Why are you using an array? You an enum; this is exactly what they are for :)
Put the enum in the global code, and you'll be able to reuse it throughout the project. I'm not entirely sure of the exact name, as it's been a while since I worked with TBH, but there's definitly something like "Globals", that I use for similar stuff.

Another tip I would give you is to first use a date, and then a month. I.e. 200802 for February 2008, and 200803 for March. The easiest way to accomplish this is by doing something along the lines of the following:

SQL: SELECT YEAR(GETDATE()) * 100 + MONTH(GETDATE())
C#: Convert.ToString(((DateTime.Now.Year * 100) + DateTime.Now.Month))

Reason for this is that it’s far easier to perform calculations and proper sorting :)

HTH.



http://entropia-online.blogspot.com/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Convering a String Array to an Integer array nkrust C# 9 November 17th, 2010 12:02 PM
Go from 2d Array to 1d array without defining type OneQuestion General .NET 1 January 10th, 2008 11:13 AM
error when sorting an Array of Array nancy VBScript 2 February 17th, 2005 12:57 PM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM
Array to Array comparison pavel Pro VB 6 0 March 24th, 2004 06:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.