PC Review

Thread Tools Rate Thread

Databinding problem with sqlhelper.executereader and a dropdownlist in VB.NET

Posts: n/a
      14th Dec 2005
Basically, I have a DropDownList control on a page that inputs a string
into a database. The user can later go back to the same page in
"update" mode to make further changes. So what I need to do is pull the
value back out of the database and pass it back to the control so that
value is pre-selected in the dropdown list. It works out except when
the field is a foreign key of another table.

Here is the code. It works out for the textbox and the first ddl, but
not for the second dll as field3 is in table 2:
Sub Bind()
Dim dr As SqlDataReader
Dim sql As String = "Select * from TABLE1 T1,TABLE2 T2 where T1.KEY2 =
T2.KEY2 AND KEY1 = " & ItemID
dr = SQLHelper.ExecuteReader(ConnectionString,
System.Data.CommandType.Text, sql)
If dr.HasRows Then
TextBox1.Text = dr("FIELD1").ToString
DDL1.SelectedIndex =
DDL2.SelectedIndex =
end if
End Sub

Reply With Quote

Thread Tools
Rate This Thread
Rate This Thread:

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
problem databinding a dropdownlist within a repeater Milsnips Microsoft ASP .NET 1 3rd Oct 2006 01:26 PM
Databinding Problem with Dropdownlist with Multiview Control in VB =?Utf-8?B?RmFidWxvdXNzaXRlcw==?= Microsoft ASP .NET 0 9th Jan 2006 05:19 PM
Databinding problem with a dropdownlist in ascx file as it runs in aspx! Nosaj Microsoft ASP .NET 2 29th Nov 2005 04:12 PM
databinding a Dropdownlist to another dropdownlist tshad Microsoft ASP .NET 8 19th Oct 2005 11:00 PM
Problem DataBinding DropDownList Control Jeff Petter Microsoft ADO .NET 0 3rd Oct 2003 02:34 AM




All times are GMT +1. The time now is 07:15 PM.