I have a question about loading a listbox from a dataset.

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

  1. Gordon

    Gordon Guest

    Hi;

    I am trying to port a windows app which works to a web
    app.

    I select a date from a calender control then use that date
    to select a corresponding record in a datset. When I
    execute the same code section where I select a record from
    a datatable I get an error message that says that the
    column I want to match is not found. Here is the code
    which is in a subroutine that is called from the calender
    date_selected event. The dataset is created in another
    subroutine. Why doesn't Asp.Net recognize the .Select
    statement but windows does ?

    Dim nRow As DataRow()
    Dim irow As DataRow
    nRow = tblCaseDocs.Select("doc_dte_due = '" &
    holdDte.ToString & "'")

    ListBox1.Items.Clear()

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

    Thanks,

    Gordon
     
    Gordon, Nov 26, 2003
    #1
    1. Advertising

  2. Gordon

    Alvin Bruney Guest

    Listbox are different beasts in the web environment so you have to do things
    a bit differently. You're going the long way around the park here. Fire your
    select and return the values in a dataset like this:
    DataSet ds = query blah blah blah
    Then bind your dataset to the list box like so

    listbox.datasource = ds;
    listbox.datatextformat = "case_id" //this is the column you want to display
    in the listbox
    listbox.databind();
    roughly

    regards
    "Gordon" <> wrote in message
    news:068e01c3b3c9$30dd3e30$...
    > Hi;
    >
    > I am trying to port a windows app which works to a web
    > app.
    >
    > I select a date from a calender control then use that date
    > to select a corresponding record in a datset. When I
    > execute the same code section where I select a record from
    > a datatable I get an error message that says that the
    > column I want to match is not found. Here is the code
    > which is in a subroutine that is called from the calender
    > date_selected event. The dataset is created in another
    > subroutine. Why doesn't Asp.Net recognize the .Select
    > statement but windows does ?
    >
    > Dim nRow As DataRow()
    > Dim irow As DataRow
    > nRow = tblCaseDocs.Select("doc_dte_due = '" &
    > holdDte.ToString & "'")
    >
    > ListBox1.Items.Clear()
    >
    > For Each irow In nRow
    > ListBox1.Items.Add(irow("case_id") & " " &
    > irow("Document_Nme"))
    > Next
    >
    > Thanks,
    >
    > Gordon
     
    Alvin Bruney, Nov 26, 2003
    #2
    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. blenderdude
    Replies:
    0
    Views:
    1,153
    blenderdude
    Aug 3, 2003
  2. DC Gringo
    Replies:
    0
    Views:
    423
    DC Gringo
    Apr 6, 2004
  3. kent
    Replies:
    1
    Views:
    910
    Andrew de la Harpe
    May 3, 2004
  4. Simon Prince
    Replies:
    2
    Views:
    3,387
    =?Utf-8?B?TWljaGFlbCBUYXlsb3I=?=
    Oct 19, 2004
  5. =?Utf-8?B?Q2hyaXM=?=

    listbox/dataset question

    =?Utf-8?B?Q2hyaXM=?=, Feb 12, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,100
    =?Utf-8?B?Q2hyaXM=?=
    Feb 13, 2005
Loading...

Share This Page