473,666 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3067
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.GetLen gth(0); r++)

ddlTypeOfTest.I tems.Add(new ListItem(TestTy pe[r,0], TestType[r,1]));

ddlTypeOfTest.D ataBind();

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

private void ddlTypeOfTest_S electedIndexCha nged(object sender,
System.EventArg s e)

{

txtMinimumScore .Text = TestType[ddlTypeOfTest.S electedIndex, 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("Frenc h Baccalaureate", "5", "")
}

foreach (TestType tt in TestTypes)
ddlTypeOfTest.I tems.Add(tt);
ddlTypeOfTest.D ataBind();

private void ddlTypeOfTest_S electedIndexCha nged(object sender,
System.EventArg s e)
{
TestType tt = ddlTypeOfTest.S electedItem 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
3920
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 purpose of filling the adjacent texbox for zip values. Or say it otherwise: how to transfer an array, filled with php to a Javascript function.
2
9616
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 select more. Also how can these choices be saved somehow so tha when the user goes to the next page the choices he made can be written to the database. For example The choices in the dropdown may be
6
7153
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 sheer data. So, I would like to do something to fill the dropdown-box on demand. I thought of maybe opening a Pop-Up window (maybe even an IE dialog box) and copying the information from there into the select box.
3
2118
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 auto-fill support is gone. How can I get auto-fill on a combobox with a dropdownstyle 'DropDown'? --
2
1411
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 would like to not fill the fields with lookups at form load time. I have a grid on a tab of this form that has six fields in it that have lookups associated with them. By lookups I mean that the dropDown in the field is populated by doing a query...
19
3984
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 and Reference Now my client needs to order 5 items, click a button and a table with 5 lines and 3 columns appears (until now easy)
3
2101
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 only the year in the db field, but also the current year to the next x years. Any ideas?
13
2188
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 and populate 2 variables and use a for-next loop to create the dropdown. The dropdown contains some 310 items! It works beautifully if I have 1 or 2 dropdowns but as soon as I add more it partially creates the 3rd and just stops until it times out!...
1
3457
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 set of 3 dropdown boxes be filled with the same values. thank you <head> <SCRIPT LANGUAGE="JavaScript" type="text/javascript"> var firstChoice2 = 0; var secondChoice2 = 0;
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8869
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8551
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.