DropDownList in a datalist

  • Thread starter Thread starter B. Sockel
  • Start date Start date
B

B. Sockel

I have created a data list and binded it to a data source with no
problem, Where i am running into a problem is when i dry and bind a
drop down list in Edit mode to a data source. The trick is that i need
to bind the drop down list to a different data source.

Does anyone know how to do this and can you provide me with an example.
Thanks.
 
Here is the Code that I have So Far

ASPX File:
<ItemTemplate>
....
<asp:LinkButton Font-Size="10" ID="btnEdit" Runat="server"
CommandName="edit" Text="Edit" />
....
</ItemTemplate>
<editTemplate>
.....
<asp:DropDownList ID="DDLEditEqu" Runat=server EnableViewState=True/>
</EditTemplate>


VB File:
Public Sub DTLEDITHost(ByVal sender As Object, ByVal e As
DataListCommandEventArgs)
DTLHostFile.EditItemIndex = e.Item.ItemIndex
'txtbxip.Text = e.Item.ItemIndex
BindTheData()

Dim objConn As SqlConnection
objConn = New
SqlConnection(ConfigurationSettings.AppSettings("Dev02_Host_Con"))
Strsql = "Select * From Equtype Order by Equipment_type"
Dim OBJCmd As New SqlCommand(Strsql, objConn)
Dim dataReader As SqlDataReader = Nothing
Dim DDLEqu As DropDownList =
CType(e.Item.FindControl("DDLEditEqu"), DropDownList)

objConn.Open()
dataReader = OBJCmd.ExecuteReader()

DDLEqu.DataSource = dataReader
DDLEqu.DataTextField = "Equipment_Type"
DDLEqu.DataValueField = "Autonbr"
DDLEqu.DataBind()
objConn.Dispose()


End Sub

The Error that i am getting is this line Here:
DDLEqu.DataSource = dataReader


This code is modified code that works with Drop down lists that are not
part of a datalist.
 
Back
Top