Using a <:listbox

Results 1 to 2 of 2

Thread: Using a <:listbox

  1. #1
    Join Date
    Dec 1969

    Default Using a <:listbox

    I am tring to populate a &#060;listbox from the database.<BR>&#060;asp:ListBox ID="branch_num" Runat="server" Rows="1" DataTextField="short_name"<BR> DataValueField="ibs_branch"&#062;&#060;/asp:ListBox&#062;<BR>In my Page_load event I have the following code:<BR> Dim str_connstring As String = "dsn=dev04;UID=ddb2btch;PWD=Db2$btch#02;"<BR> Dim connDb2 As New Odbc.OdbcConnection(str_connstring)<BR> connDb2.Open()<BR><BR> Dim str_sql As String = "SELECT ibs_branch, short_name FROM db2ib.ibtbrch"<BR><BR> Dim objCmd As New Odbc.OdbcCommand(str_sql, connDb2)<BR><BR> &#039;Create/Populate the DataReader<BR> Dim objDR As Odbc.OdbcDataReader<BR> objDR = objCmd.ExecuteReader()<BR> &#039;Databind the DataReader to the listbox Web control<BR>***error branch_num.DataSource = objDR<BR>***error branch_num.DataBind()<BR>*** branch_num is not declared.<BR>How do I link the datasource to the listbox<BR>

  2. #2
    Join Date
    Dec 1969

    Default I'll just hazard a guess

    If you are using a code behind page for your code then you need to declare all controls in the code behind which you use in the page. So it this case you would need to do<BR><BR>Dim branch_num as listBox

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts