p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 19th, 2006, 06:47 PM
Registered User
 
Join Date: Feb 2006
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Populating a drop down list from an ArrayList

Hi,

I'm successfully populating a drop down list from an ArrayList that I've in turn populated from a SQL DB using a reader.

Here's my code:

Code:
    Public Function PopulateModuleDropDown() As ArrayList

        'declare variables
        Dim arrModules As New ArrayList
        Dim strSqlStatement As String = "SELECT ModuleName From Modules"
        Dim cmdPMDD As New SqlCommand(strSqlStatement, nurseConnection)
        cmdPMDD.CommandType = CommandType.Text
        Dim drPMDD As SqlDataReader

        Try
            'open connection to the database
            nurseConnection.Open()

            'execute reader, then close the connection
            drPMDD = cmdPMDD.ExecuteReader(CommandBehavior.CloseConnection)

            While drPMDD.Read()
                arrModules.Add(drPMDD("ModuleName"))
            End While

            'drPMDD.Close()

            Return arrModules

        Catch ex As Exception
            ex.ToString()
        End Try

    End Function
My problem is that because the ArrayList is 0-based, when I choose an option from the drop down list, the results are always off by 1.

Again, my code:

Code:
    Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        'For each question in the SQL DB, create a label and insert the question into it

        Dim dsAQ As DataSet = DA.QuestionsDataSet(ddlModule.SelectedIndex)
        Dim i As Integer = 0
        Dim strTest As String
        Dim strQuestionText As String

        Do While i <= dsAQ.Tables(0).Rows.Count - 1

            strQuestionText = dsAQ.Tables(0).Rows(i).Item("Question")
            'If strQuestionText <> strTest Then
            'strTest = strQuestionText
            Dim lblQuestion As New Label
            lblPlaceHolder.Controls.Add(lblQuestion)
            lblQuestion.Text = strQuestionText
            'End If

            i += 1

        Loop
    End Sub
So in other words, say the user chooses the second item in the ddl, "Module Two". The code in the button_click event should return text related to Module Two, but returns text related to Module One instead. How do I fix this? It must be a simple fix, but I'm flying blind.

Thanks in advance for any help!
Jens

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old April 20th, 2006, 12:14 PM
Registered User
 
Join Date: Feb 2006
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's ok... I figured it out.
Thanks


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Populating web form with drop down list selection AugieDawgie ASP.NET 1.0 and 1.1 Basics 0 December 7th, 2005 11:44 AM
populating a drop down with a file list cjcd ASP.NET 1.0 and 1.1 Professional 2 April 18th, 2004 11:37 AM
populating a drop down with a file list cjcd BOOK: Beginning ASP.NET 1.0 1 April 17th, 2004 03:53 AM
populating a drop down with a file list cjcd ASP.NET 1.1 1 April 16th, 2004 10:55 PM
Populating Drop Down based on other drop down jeffbarclay Java Databases 1 November 7th, 2003 12:14 PM



All times are GMT -4. The time now is 11:39 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc