multiple dropdown lists = multiple data readers???

Discussion in 'ASP .Net' started by Andrew Kidd, Apr 20, 2004.

  1. Andrew Kidd

    Andrew Kidd Guest

    Hi,

    I've have a form for the user to fill in which comprises of 5 date ranges,
    each made up of a "FROM" & "TO" date, which is built from a "[Month]"
    dropdownlist & a "[Day]" dropdownlist, as follows:

    Period 1 = FROM [Month][day] TO [Month][Day]
    Period 2 = FROM [Month][day] TO [Month][Day]
    Period 3 = FROM [Month][day] TO [Month][Day]
    Period 4 = FROM [Month][day] TO [Month][Day]
    Period 5 = FROM [Month][day] TO [Month][Day]

    Ordinarily I use the following code to bind up a dropdownlist:

    If IsPostBack = False Then
    Dim objCn As New Odbc.OdbcConnection("DSN=IRS")
    Dim objCmd As New Odbc.OdbcCommand("SELECT DISTINCT
    tblHoliday.Country FROM tblHoliday", objCn)
    Dim objDr As Odbc.OdbcDataReader

    objCn.Open()
    objDr = objCmd.ExecuteReader

    Me.cboCountries.DataSource = objDr

    Me.cboCountries.DataTextField = "Country"
    Me.cboCountries.DataValueField = "Country"
    Me.cboCountries.DataBind()
    objDr.Close()
    objCn.Close()

    End If

    I've got the months and days each in a separate lookup table, but I'm faced
    with the prospect of having to run the above routine 10 times each for both
    the days and months in order to populate the combos.

    Is there an easier way to do this?

    Thanks in advance

    Andy
     
    Andrew Kidd, Apr 20, 2004
    #1
    1. Advertising

  2. Andrew Kidd

    Andrew Kidd Guest

    Doh!

    Sussed it.

    "Andrew Kidd" <> wrote in message
    news:%...
    > Hi,
    >
    > I've have a form for the user to fill in which comprises of 5 date ranges,
    > each made up of a "FROM" & "TO" date, which is built from a "[Month]"
    > dropdownlist & a "[Day]" dropdownlist, as follows:
    >
    > Period 1 = FROM [Month][day] TO [Month][Day]
    > Period 2 = FROM [Month][day] TO [Month][Day]
    > Period 3 = FROM [Month][day] TO [Month][Day]
    > Period 4 = FROM [Month][day] TO [Month][Day]
    > Period 5 = FROM [Month][day] TO [Month][Day]
    >
    > Ordinarily I use the following code to bind up a dropdownlist:
    >
    > If IsPostBack = False Then
    > Dim objCn As New Odbc.OdbcConnection("DSN=IRS")
    > Dim objCmd As New Odbc.OdbcCommand("SELECT DISTINCT
    > tblHoliday.Country FROM tblHoliday", objCn)
    > Dim objDr As Odbc.OdbcDataReader
    >
    > objCn.Open()
    > objDr = objCmd.ExecuteReader
    >
    > Me.cboCountries.DataSource = objDr
    >
    > Me.cboCountries.DataTextField = "Country"
    > Me.cboCountries.DataValueField = "Country"
    > Me.cboCountries.DataBind()
    > objDr.Close()
    > objCn.Close()
    >
    > End If
    >
    > I've got the months and days each in a separate lookup table, but I'm

    faced
    > with the prospect of having to run the above routine 10 times each for

    both
    > the days and months in order to populate the combos.
    >
    > Is there an easier way to do this?
    >
    > Thanks in advance
    >
    > Andy
    >
    >
    >
     
    Andrew Kidd, Apr 21, 2004
    #2
    1. Advertising

  3. Andrew Kidd

    Rick Spiewak Guest

    Read the data once, into an array or arraylist, and bind all the
    dropdownlists to that.

    "Andrew Kidd" <> wrote in message
    news:%...
    > Hi,
    >
    > I've have a form for the user to fill in which comprises of 5 date ranges,
    > each made up of a "FROM" & "TO" date, which is built from a "[Month]"
    > dropdownlist & a "[Day]" dropdownlist, as follows:
    >
    > Period 1 = FROM [Month][day] TO [Month][Day]
    > Period 2 = FROM [Month][day] TO [Month][Day]
    > Period 3 = FROM [Month][day] TO [Month][Day]
    > Period 4 = FROM [Month][day] TO [Month][Day]
    > Period 5 = FROM [Month][day] TO [Month][Day]
    >
    > Ordinarily I use the following code to bind up a dropdownlist:
    >
    > If IsPostBack = False Then
    > Dim objCn As New Odbc.OdbcConnection("DSN=IRS")
    > Dim objCmd As New Odbc.OdbcCommand("SELECT DISTINCT
    > tblHoliday.Country FROM tblHoliday", objCn)
    > Dim objDr As Odbc.OdbcDataReader
    >
    > objCn.Open()
    > objDr = objCmd.ExecuteReader
    >
    > Me.cboCountries.DataSource = objDr
    >
    > Me.cboCountries.DataTextField = "Country"
    > Me.cboCountries.DataValueField = "Country"
    > Me.cboCountries.DataBind()
    > objDr.Close()
    > objCn.Close()
    >
    > End If
    >
    > I've got the months and days each in a separate lookup table, but I'm

    faced
    > with the prospect of having to run the above routine 10 times each for

    both
    > the days and months in order to populate the combos.
    >
    > Is there an easier way to do this?
    >
    > Thanks in advance
    >
    > Andy
    >
    >
    >
     
    Rick Spiewak, Apr 22, 2004
    #3
  4. Andrew Kidd

    Andrew Kidd Guest

    Cheers Rick!

    "Rick Spiewak" <> wrote in message
    news:...
    > Read the data once, into an array or arraylist, and bind all the
    > dropdownlists to that.
    >
    > "Andrew Kidd" <> wrote in message
    > news:%...
    > > Hi,
    > >
    > > I've have a form for the user to fill in which comprises of 5 date

    ranges,
    > > each made up of a "FROM" & "TO" date, which is built from a "[Month]"
    > > dropdownlist & a "[Day]" dropdownlist, as follows:
    > >
    > > Period 1 = FROM [Month][day] TO [Month][Day]
    > > Period 2 = FROM [Month][day] TO [Month][Day]
    > > Period 3 = FROM [Month][day] TO [Month][Day]
    > > Period 4 = FROM [Month][day] TO [Month][Day]
    > > Period 5 = FROM [Month][day] TO [Month][Day]
    > >
    > > Ordinarily I use the following code to bind up a dropdownlist:
    > >
    > > If IsPostBack = False Then
    > > Dim objCn As New Odbc.OdbcConnection("DSN=IRS")
    > > Dim objCmd As New Odbc.OdbcCommand("SELECT DISTINCT
    > > tblHoliday.Country FROM tblHoliday", objCn)
    > > Dim objDr As Odbc.OdbcDataReader
    > >
    > > objCn.Open()
    > > objDr = objCmd.ExecuteReader
    > >
    > > Me.cboCountries.DataSource = objDr
    > >
    > > Me.cboCountries.DataTextField = "Country"
    > > Me.cboCountries.DataValueField = "Country"
    > > Me.cboCountries.DataBind()
    > > objDr.Close()
    > > objCn.Close()
    > >
    > > End If
    > >
    > > I've got the months and days each in a separate lookup table, but I'm

    > faced
    > > with the prospect of having to run the above routine 10 times each for

    > both
    > > the days and months in order to populate the combos.
    > >
    > > Is there an easier way to do this?
    > >
    > > Thanks in advance
    > >
    > > Andy
    > >
    > >
    > >

    >
    >
     
    Andrew Kidd, Apr 22, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==

    List of lists of lists of lists...

    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==, May 8, 2006, in forum: Python
    Replies:
    5
    Views:
    445
    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==
    May 15, 2006
  2. raven
    Replies:
    0
    Views:
    321
    raven
    Jul 12, 2007
  3. Replies:
    2
    Views:
    462
  4. Tom Nowak

    Data Readers

    Tom Nowak, Jul 2, 2010, in forum: ASP .Net
    Replies:
    1
    Views:
    387
    Mr. Arnold
    Jul 2, 2010
  5. Andrew Kidd

    multiple dropdown lists = multiple data readers???

    Andrew Kidd, Apr 20, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    209
    Andrew Kidd
    Apr 21, 2004
Loading...

Share This Page