[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

for loop for dropdownlist

Hi, I would like to have a for loop which fills the same values from a database into 3 dropdownlists
Something like this:

for (int i = 0; i < 3 ; i++)
{
DropDownList4.DataSource = cmd.ExecuteReader();
DropDownList4.DataTextField = "USER_NAME";
DropDownList4.DataValueField = "USER_NAME";
DropDownList4.DataBind();
}

Where as the number 4 should be replaced by the i value. Is that possible?

Cheers

Chris
0
ccoe1
Asked:
ccoe1
  • 2
1 Solution
 
TDSnetCommented:
Hi Chris,

Sounds like you could benefit from the implementation of a Control Array.  Then you could just use your (i) value to represent the index value of the array.  For an easy-to-follow example of implementing Control Arrays in C# go to:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchcreatingcontrolarraysinvisualbasicnetvisualcnet.asp

Hope this helps.

Cheers,

Jack Pick
Total Data Solutions
0
 
TDSnetCommented:
I believe my answer was helpful.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now