Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > How do I fill a list box through code on a web page ?

Thread Tools

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

Posts: n/a

I am a novice developer who would like to create
a dataset-table and then use the 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.




Public Sub SetUpDataBinding()

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


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)",
Dim ds As New DataSet
daDocs.Fill(dsCases, "tblCaseDocs")
Session("dsCases") = dsCases

holdDte = Today

Catch ex As System.Data.SqlClient.SqlException

HttpContext.Current.Request.UserHostAddress = ""
Session("CurrentError") = ex.Message
Session("CurrentError") = "Error
processing page."
End If
' 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 ?? )))


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

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

End Sub

Reply With Quote

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
div box questions; float text around a box, fit box to image size Gnarlodious HTML 4 05-05-2010 11:30 AM
?How to code for printing image to fill page. gil HTML 2 01-09-2006 05:23 PM
Fill Combo Box based on another Combo Box dthmtlgod ASP General 1 11-16-2005 04:08 PM
populate one list box with selected values from another list box ASP .Net 1 03-12-2005 11:29 PM