How do I fill a list box through code on a web page ?

Discussion in 'ASP .Net Web Controls' started by Gordon, Nov 26, 2003.

  1. Gordon

    Gordon Guest

    Hi;

    I am a novice asp.net developer who would like to create
    a dataset-table and then use the datatable.select cmd. to
    look up a value passed from the web calander control. The
    value(s) would then be used to populate a listbox on the
    web form. Here is the following code that I tried. It is
    called from the date selected event of the calender
    control. I know that I need to create the datatable only
    one time and then save in a variable.

    Thanks,

    Gordon

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

    Public Sub SetUpDataBinding()

    Dim datConn As String = "Integrated
    Security=SSPI;Initial Catalog=DocsDates;Data Source=
    (local)\vsdotnet"
    Dim cnDocDates As New SqlConnection(datConn)

    Try

    Dim cmdGetCases As New SqlCommand
    ("CMasterSelectCommand", cnDocDates)
    Dim daCases As New SqlDataAdapter("SELECT
    case_id, lname, case_status from CaseMaster", cnDocDates)
    Dim daDocs As New SqlDataAdapter("SELECT
    case_id, document_nme, doc_dte_start, " & _
    "doc_dte_due, comments from CaseDocs where
    case_id in " & _
    "(SELECT case_id from CaseMaster)",
    cnDocDates)
    Dim ds As New DataSet
    daDocs.Fill(dsCases, "tblCaseDocs")
    Session("dsCases") = dsCases

    holdDte = Today


    Catch ex As System.Data.SqlClient.SqlException

    If
    HttpContext.Current.Request.UserHostAddress = "129.0.0.5"
    Then
    Session("CurrentError") = ex.Message
    Else
    Session("CurrentError") = "Error
    processing page."
    End If
    Server.Transfer("ApplicationError.aspx")
    Finally
    ' cnDocDates.Close()
    End Try

    End Sub


    Public Sub ListBoxFill() ((( This called when a date
    is selected on the calendar web control )))))

    Dim myCol As DataColumn
    Dim myRow As DataRow
    Dim currRows() As DataRow


    Dim nRow As DataRow()
    Dim irow As DataRow

    nRow = tblCaseDocs.Select("doc_dte_due = '" &
    holdDte.ToString & "'") ((( I get an error on the web page
    when I click on a date saying that the table column
    [doc_dte_due] isn't found ?? )))

    ListBox1.Items.Clear()

    For Each irow In nRow
    ListBox1.Items.Add(irow("case_id") & " " &
    irow("Document_Nme"))
    Next

    ListBox1.DataBind() (((( Do I need this ? )))

    End Sub
     
    Gordon, Nov 26, 2003
    #1
    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. Gnarlodious
    Replies:
    4
    Views:
    17,704
    elizas
    May 5, 2010
  2. David
    Replies:
    4
    Views:
    144
    Bob Barrows [MVP]
    Nov 3, 2004
  3. Eugene Anthony

    fill combo box with data from database

    Eugene Anthony, Jul 14, 2005, in forum: ASP General
    Replies:
    4
    Views:
    158
    Bob Barrows [MVP]
    Jul 14, 2005
  4. dthmtlgod

    Fill Combo Box based on another Combo Box

    dthmtlgod, Nov 16, 2005, in forum: ASP General
    Replies:
    1
    Views:
    622
    Bob Barrows [MVP]
    Nov 16, 2005
  5. RelaxoRy
    Replies:
    1
    Views:
    133
    Geoff Tucker
    Feb 25, 2004
Loading...

Share This Page