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

what's a neater way of writing this simple code...

I'm populating a dropdown list with non-consecutive values (well the
last 3 values are non-consecutive anyway).. What's a shorter way of
writing the following?...

ddLetMaxPrice.Items.Insert(0, New ListItem("No Preference", 999999))
ddLetMaxPrice.Items.Insert(1, New ListItem("100", 100))
ddLetMaxPrice.Items.Insert(2, New ListItem("200", 200))
ddLetMaxPrice.Items.Insert(3, New ListItem("300", 300))
ddLetMaxPrice.Items.Insert(4, New ListItem("400", 400))
ddLetMaxPrice.Items.Insert(5, New ListItem("500", 500))
ddLetMaxPrice.Items.Insert(6, New ListItem("600", 600))
ddLetMaxPrice.Items.Insert(7, New ListItem("700", 700))
ddLetMaxPrice.Items.Insert(8, New ListItem("800", 800))
ddLetMaxPrice.Items.Insert(9, New ListItem("900", 900))
ddLetMaxPrice.Items.Insert(10, New ListItem("1200", 1200))
ddLetMaxPrice.Items.Insert(11, New ListItem("1400", 1400))
ddLetMaxPrice.Items.Insert(12, New ListItem("1600", 1600))
ddLetMaxPrice.Items.Insert(13, New ListItem("1800", 1800))
ddLetMaxPrice.Items.Insert(14, New ListItem("2000+", 999999))

All I can seem to find on the net is to populate an ArrayList with the
values and then use the arraylist as a datasource, but that also
involves a line of code per item.

I'm looking for something like:

var aMaxPriceName = new Array("Not Selected", "2,000", "2,500", "3,000",
"3,500", "4,000", "4,500", "5,000+");
var aMaxPriceValue = new Array(999999999999, 2000, 2500,
3000, 3500, 4000, 4500, 999999999999);

and then to bind that array to the dropdownlist.
Any ideas?
--

"I hear ma train a comin'
.... hear freedom comin"
Nov 19 '05 #1
5 1197
You could try something like this:

Dim List() As String = {100, 200, 300, 400, 500, 600, 700}
DropDownList3.DataSource = List
DropDownList3.DataBind()
DropDownList3.Items.Insert(0, New ListItem("No preference",
999999))
DropDownList3.Items.Insert(DropDownList3.Items.Cou nt, New
ListItem("2000+", 999999))

Hope that helps,
Scott

Nov 19 '05 #2
vb.net? or c#
Stimp wrote:
I'm populating a dropdown list with non-consecutive values (well the
last 3 values are non-consecutive anyway).. What's a shorter way of
writing the following?...

ddLetMaxPrice.Items.Insert(0, New ListItem("No Preference", 999999))
ddLetMaxPrice.Items.Insert(1, New ListItem("100", 100))
ddLetMaxPrice.Items.Insert(2, New ListItem("200", 200))
ddLetMaxPrice.Items.Insert(3, New ListItem("300", 300))
ddLetMaxPrice.Items.Insert(4, New ListItem("400", 400))
ddLetMaxPrice.Items.Insert(5, New ListItem("500", 500))
ddLetMaxPrice.Items.Insert(6, New ListItem("600", 600))
ddLetMaxPrice.Items.Insert(7, New ListItem("700", 700))
ddLetMaxPrice.Items.Insert(8, New ListItem("800", 800))
ddLetMaxPrice.Items.Insert(9, New ListItem("900", 900))
ddLetMaxPrice.Items.Insert(10, New ListItem("1200", 1200))
ddLetMaxPrice.Items.Insert(11, New ListItem("1400", 1400))
ddLetMaxPrice.Items.Insert(12, New ListItem("1600", 1600))
ddLetMaxPrice.Items.Insert(13, New ListItem("1800", 1800))
ddLetMaxPrice.Items.Insert(14, New ListItem("2000+", 999999))

All I can seem to find on the net is to populate an ArrayList with the
values and then use the arraylist as a datasource, but that also
involves a line of code per item.

I'm looking for something like:

var aMaxPriceName = new Array("Not Selected", "2,000", "2,500", "3,000",
"3,500", "4,000", "4,500", "5,000+");
var aMaxPriceValue = new Array(999999999999, 2000, 2500,
3000, 3500, 4000, 4500, 999999999999);

and then to bind that array to the dropdownlist.
Any ideas?
--

"I hear ma train a comin'
... hear freedom comin"


Nov 19 '05 #3
Either.. I'm working in VB, but can translate from C# :)

On Fri, 14 Oct 2005 parez <ps*****@gmail.com> wrote:
vb.net? or c#
Stimp wrote:
I'm populating a dropdown list with non-consecutive values (well the
last 3 values are non-consecutive anyway).. What's a shorter way of
writing the following?...

ddLetMaxPrice.Items.Insert(0, New ListItem("No Preference", 999999))
ddLetMaxPrice.Items.Insert(1, New ListItem("100", 100))
ddLetMaxPrice.Items.Insert(2, New ListItem("200", 200))
ddLetMaxPrice.Items.Insert(3, New ListItem("300", 300))
ddLetMaxPrice.Items.Insert(4, New ListItem("400", 400))
ddLetMaxPrice.Items.Insert(5, New ListItem("500", 500))
ddLetMaxPrice.Items.Insert(6, New ListItem("600", 600))
ddLetMaxPrice.Items.Insert(7, New ListItem("700", 700))
ddLetMaxPrice.Items.Insert(8, New ListItem("800", 800))
ddLetMaxPrice.Items.Insert(9, New ListItem("900", 900))
ddLetMaxPrice.Items.Insert(10, New ListItem("1200", 1200))
ddLetMaxPrice.Items.Insert(11, New ListItem("1400", 1400))
ddLetMaxPrice.Items.Insert(12, New ListItem("1600", 1600))
ddLetMaxPrice.Items.Insert(13, New ListItem("1800", 1800))
ddLetMaxPrice.Items.Insert(14, New ListItem("2000+", 999999))

All I can seem to find on the net is to populate an ArrayList with the
values and then use the arraylist as a datasource, but that also
involves a line of code per item.

I'm looking for something like:

var aMaxPriceName = new Array("Not Selected", "2,000", "2,500", "3,000",
"3,500", "4,000", "4,500", "5,000+");
var aMaxPriceValue = new Array(999999999999, 2000, 2500,
3000, 3500, 4000, 4500, 999999999999);

and then to bind that array to the dropdownlist.
Any ideas?
--

"I hear ma train a comin'
... hear freedom comin"

--

"I hear ma train a comin'
.... hear freedom comin"
Nov 19 '05 #4
Stimp,

I think you could bind an array vs. the array list that would be easier to
populate.

Dim MyArray as String() = { "100", "200", "300" }

lstPizzaTopping.DataSource = MyArray
lstPizzaTopping.DataBind()
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Stimp" <re*@spumco.com> wrote in message
news:sl****************@carbon.redbrick.dcu.ie...
I'm populating a dropdown list with non-consecutive values (well the
last 3 values are non-consecutive anyway).. What's a shorter way of
writing the following?...

ddLetMaxPrice.Items.Insert(0, New ListItem("No Preference", 999999))
ddLetMaxPrice.Items.Insert(1, New ListItem("100", 100))
ddLetMaxPrice.Items.Insert(2, New ListItem("200", 200))
ddLetMaxPrice.Items.Insert(3, New ListItem("300", 300))
ddLetMaxPrice.Items.Insert(4, New ListItem("400", 400))
ddLetMaxPrice.Items.Insert(5, New ListItem("500", 500))
ddLetMaxPrice.Items.Insert(6, New ListItem("600", 600))
ddLetMaxPrice.Items.Insert(7, New ListItem("700", 700))
ddLetMaxPrice.Items.Insert(8, New ListItem("800", 800))
ddLetMaxPrice.Items.Insert(9, New ListItem("900", 900))
ddLetMaxPrice.Items.Insert(10, New ListItem("1200", 1200))
ddLetMaxPrice.Items.Insert(11, New ListItem("1400", 1400))
ddLetMaxPrice.Items.Insert(12, New ListItem("1600", 1600))
ddLetMaxPrice.Items.Insert(13, New ListItem("1800", 1800))
ddLetMaxPrice.Items.Insert(14, New ListItem("2000+", 999999))

All I can seem to find on the net is to populate an ArrayList with the
values and then use the arraylist as a datasource, but that also
involves a line of code per item.

I'm looking for something like:

var aMaxPriceName = new Array("Not Selected", "2,000", "2,500", "3,000",
"3,500", "4,000", "4,500", "5,000+");
var aMaxPriceValue = new Array(999999999999, 2000, 2500,
3000, 3500, 4000, 4500, 999999999999);

and then to bind that array to the dropdownlist.
Any ideas?
--

"I hear ma train a comin'
... hear freedom comin"

Nov 19 '05 #5
On Fri, 14 Oct 2005 Sc***********@excite.com <Sc***********@excite.com> wrote:
You could try something like this:

Dim List() As String = {100, 200, 300, 400, 500, 600, 700}
DropDownList3.DataSource = List
DropDownList3.DataBind()
DropDownList3.Items.Insert(0, New ListItem("No preference",
999999))
DropDownList3.Items.Insert(DropDownList3.Items.Cou nt, New
ListItem("2000+", 999999))


that's probably the best I can do.. thanks!
--

"I hear ma train a comin'
.... hear freedom comin"
Nov 19 '05 #6

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

Similar topics

3
by: Chris Cioffi | last post by:
I started writing this list because I wanted to have definite points to base a comparison on and as the starting point of writing something myself. After looking around, I think it would be a...
92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
30
by: Reinhold Birkenfeld | last post by:
Hello, I know that there are different YAML engines for Python out there (Syck, PyYaml, more?). Which one do you use, and why? For those of you who don't know what YAML is: visit...
137
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very...
2
by: Ross Clement (Email address invalid - do not use) | last post by:
Hi. I would like to make a typedef for a structure which can be joined up into a linked list. I include my code below. My code works, but I have a vague suspicion that I could have declared my...
31
by: Mason | last post by:
I've been working to become competent at making websites. My learning path has been: html -css- paintshop pro -javascript -php/mysql I'm getting somewhat proficient at php/mysql (although I...
8
by: Shelly | last post by:
I get an error that the input string is not in the right format. Here is the result: Here is the partial code: Dim sqlConn As New SqlConnection(SqlDataSource1.ConnectionString) Dim query As...
6
by: raphfrk | last post by:
While I am here, I just thought I'd ask if there is a recommended way of handling 2d dynamic arrays. I implement them using the following kind of code. ...
5
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i'm trying to capture only numeric keys and was wondering if there was a neater or compact way of writing the following snippet? thanks, rodchar private void...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.