473,408 Members | 2,832 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,408 software developers and data experts.

Fill Dropdown From Array

Hi. I'm new to C# especially to arrays. I need a 3 dimension array to
fill a dropdown list in a web page.

TypeOfTest | MinPoint | Value

I'll use Type of Test and Value in dropdown. MinPoint will be shown in a
label near dropdown.

Can u help me?
Jun 5 '06 #1
3 3051
Array is like that: (2 dimension, i said 3 in first message sorry)

string[,] TestType = { {"SAT1", "1", "1000"},

{"ACT", "2", "21"},

{"GCE 2 Certificates", "3", "2 Course"},

{"IB International Baccalaureate", "4", ""},

{"French Baccalaureate", "5", ""},
Jun 5 '06 #2
for (int r = 0; r < TestType.GetLength(0); r++)

ddlTypeOfTest.Items.Add(new ListItem(TestType[r,0], TestType[r,1]));

ddlTypeOfTest.DataBind();

-----------------------------------

private void ddlTypeOfTest_SelectedIndexChanged(object sender,
System.EventArgs e)

{

txtMinimumScore.Text = TestType[ddlTypeOfTest.SelectedIndex, 2];

}
Jun 5 '06 #3

LacOniC wrote:
Array is like that: (2 dimension, i said 3 in first message sorry)

string[,] TestType = { {"SAT1", "1", "1000"},

{"ACT", "2", "21"},

{"GCE 2 Certificates", "3", "2 Course"},

{"IB International Baccalaureate", "4", ""},

{"French Baccalaureate", "5", ""},


Actually, what you need is a 1-dimension array of objects:

class TestType
{
public string TypeOfTest;
public string MinPoint;
public string Value;
public TestType (string tt, string mp, string v)
{
TypeOfTest = tt;
MinPoint = mp;
Value = v;
}
public override string ToString()
{
return String.Format("{0} | {1} | {2}", TypeOfTest,
MinPoint, Value);
}
}
TestType [] TestTypes = new TestType[] {
new TestType("SAT1", "1", "1000"),
new TestType("ACT", "2", "21"),
new TestType("GCE 2 Certificates", "3", "2 Course"),
new TestType("IB International Baccalaureate", "4",
""),
new TestType("French Baccalaureate", "5", "")
}

foreach (TestType tt in TestTypes)
ddlTypeOfTest.Items.Add(tt);
ddlTypeOfTest.DataBind();

private void ddlTypeOfTest_SelectedIndexChanged(object sender,
System.EventArgs e)
{
TestType tt = ddlTypeOfTest.SelectedItem as TestType;
txtMinimumScore.Text = tt.Value;
}

Jun 5 '06 #4

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

Similar topics

0
by: Erwin Radermacher | last post by:
Hello dear PHP users, I have a form with text boxes and a dropdown menu with names of cities The adjacent textbox fills by the help of a Javascript function. My question is, how to realize the...
2
by: Jas | last post by:
I want an ASP page with a dropdown and a simple button. Every time the user chooses an item from the dropdown and clicks on the button i want that value written below in list and allow user to...
6
by: Jochen Daum | last post by:
Hi ! I have a page with a large amount of dropdowns, which are quite big sometimes. All these are generated with PHP. Some timing tests tell me that the problem is not the database, but the...
3
by: Maurice Mertens | last post by:
Hi all, In VB.NET you can set the DropDownStyle for a combobox to 'DropDown' or 'DropDownList'. When you set it to DropDownList, it supports auto-fill. But when you set it to 'DropDown', the...
2
by: Woody Splawn | last post by:
I have a question about technique with regard to filling drop downs. I have a Winform that has several different tabs and tables associated with it. In an effort to keep the load time small I...
19
by: Alex | last post by:
Hello list This question has probably already been asked, but let me ask again I have a mysql database to which I connect with my php scripts. The database contains articles. Name, Unit_Price...
3
by: Advertis | last post by:
Is there a way to populate a dropdown in a GridView with the next x years? I am using a GridView to display data from a SQL table One of the fields is a Year. I want to have the dropdown list not...
13
by: Shutey | last post by:
I have a strange issue with dropdowns. Using php4, mySQL5, Apache 2 on a fast XP pro PC, I have a form which requires 5 dropdowns populated with indentical values. I extract the values using SQL...
1
by: bytesFTW99 | last post by:
I have been struggling with this for some time can anyone help out? just trying to have 3 dropdown boxes that fill depending on what is selected, then in some cases click a button and have the second...
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.