Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > dropdown list to select day,month & year using for loop

Reply
Thread Tools

dropdown list to select day,month & year using for loop

 
 
sonum
Guest
Posts: n/a
 
      04-15-2009
I am creating a custom control with 3 dropdownlists (day, month,
year)
which I will use as a date selector. I want to be able to reuse all my
code
and cut programming repetition down a lot (I don't mind spending a lot
of
time on something if I don't have to do it again).

My question is, with the day selector, how should I store a list of
numbers
from 1 to 31 to bind to the dropdownlistbox? I could run a loop and
create
it like that but why not just have an existing array or enum or
something.


With the month selector I am using an enumerator to hold all the month
names
but it doesnt seem efficient to use one for a list of numbers.


Does anyone have any suggestions? If you help me out I will even give
you
this control when I'm finished (and anyone who wants it).


 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      04-15-2009
On Apr 15, 12:03*pm, sonum <career.sownda...@gmail.com> wrote:
> I am creating *a custom control with 3 dropdownlists (day, month,
> year)
> which I will use as a date selector. I want to be able to reuse all my
> code
> and cut programming repetition down a lot (I don't mind spending a lot
> of
> time on something if I don't have to do it again).
>
> My question is, with the day selector, how should I store a list of
> numbers
> from 1 to 31 to bind to the dropdownlistbox? I could run a loop and
> create
> it like that but why not just have an existing array or enum or
> something.
>
> With the month selector I am using an enumerator to hold all the month
> names
> but it doesnt seem efficient to use one for a list of numbers.
>
> Does anyone have any suggestions? If you help me out I will even give
> you
> this control when I'm finished (and anyone who wants it).


if you don't need to have local translation of names, then you can
just have

Months() As String = {"January", "February", "March", "April", "May",
"June", "July", "August", "September", "October", "November",
"December"}
 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      04-15-2009
WIndows forms or ASP.NET?

With WIndows forms, you can rebuild the days, based on the year and month
(overall month, but you do have February changing based on year). With
ASP.NET, you rebuild the select with JavaScript, which means you have to
emit it.

The other issue you have is one of culture. Not as big with a windows app,
as you simply change config elements. With a web control, however, you
either have to ship the resource file with the control (not impossible, but
a bit more difficult, as it is an extra file to have missing) or you have to
encapsulate the logic, which means you have to do more work up front.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

*********************************************
| Think outside the box |
*********************************************
"sonum" <> wrote in message
news:a45a8398-3bf7-4749-b0ef-...
>I am creating a custom control with 3 dropdownlists (day, month,
> year)
> which I will use as a date selector. I want to be able to reuse all my
> code
> and cut programming repetition down a lot (I don't mind spending a lot
> of
> time on something if I don't have to do it again).
>
> My question is, with the day selector, how should I store a list of
> numbers
> from 1 to 31 to bind to the dropdownlistbox? I could run a loop and
> create
> it like that but why not just have an existing array or enum or
> something.
>
>
> With the month selector I am using an enumerator to hold all the month
> names
> but it doesnt seem efficient to use one for a list of numbers.
>
>
> Does anyone have any suggestions? If you help me out I will even give
> you
> this control when I'm finished (and anyone who wants it).
>
>


 
Reply With Quote
 
Andrew Morton
Guest
Posts: n/a
 
      04-15-2009
Cowboy (Gregory A. Beamer) wrote:
> The other issue you have is one of culture. Not as big with a windows
> app, as you simply change config elements. With a web control,
> however, you either have to ship the resource file with the control
> (not impossible, but a bit more difficult, as it is an extra file to
> have missing) or you have to encapsulate the logic, which means you
> have to do more work up front.


With a web app it's as simple as generating the month names server-side if,
in the <system.web> section of web.config, you have

<globalization culture="auto" uiCulture="auto" />

That way, datetimeVar.tostring("MMMM") will generate month names in the
language the browser says it's set to.

If that's what you meant by the culture issue...

Andrew


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Triple nested loop python (While loop insde of for loop inside ofwhile loop) Isaac Won Python 9 03-04-2013 10:08 AM
Re: How to loop through a list while inside the loop, the list size may be decreased? Roedy Green Java 3 09-13-2008 01:51 AM
Learning : Loop to list all dropdown box values on a form Nick Calladine Javascript 3 06-15-2005 09:08 PM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM
Select dropdown box bleeds into Javascript dropdown menu Mike HTML 1 12-18-2003 09:49 PM



Advertisments