ASP.NET Data Controls Part 3: DataList
Subject:   Implementing a DropDownList in Edit Mode in a DataList
Date:   2003-11-05 14:32:59
From:   anonymous2
Hey your article is very nice and helped me build a datalist control. Although I have one problem I want to Implement a Drop Down List in the edit mode in order to let users update "Languages" or "Countries" through an existing DB table. Here is my code can you please help me?

.aspx FILE

<asp:DropDownList Height="18" Width="250" Font-Size="8" Runat="server" ID="ddlLibraryPrintLanguage"></asp:DropDownList>

.aspx.vb FILE

Public Sub GetLanguages()

Dim objLibrary_DAL As Library_DAL = New Library_DAL()

With ddlLibraryPrintLanguage
.DataSource = objLibrary_DAL.GetLibraryLanguage
.DataTextField = "LanguageDesc"
.DataValueField = "LanguageID"

Dim liLibraryLanguage As ListItem = New ListItem("- Select Language -")
.Items.Insert(0, liLibraryLanguage)

End With

End Sub

Sub Edit_CommandPrint(ByVal sender As Object, _
ByVal e As DataListCommandEventArgs)
' to rebind the DataList to the data source to
' refresh the control.
dlLibraryPrintDetail.EditItemIndex = e.Item.ItemIndex

Library_Dal.vb (Data Access Layer)

Public Function GetLibraryLanguage() As SqlDataReader

Dim objConn As New SqlConnection(ConfigurationSettings.AppSettings("strConnection"))
Dim objCmd As New SqlCommand("csp_GetLanguage", objConn)

objCmd.CommandType = CommandType.StoredProcedure

Dim Result As SqlDataReader = objCmd.ExecuteReader(CommandBehavior.CloseConnection)

Return Result

End Function

End Sub

1 to 1 of 1
  1. Implementing a DropDownList in Edit Mode in a DataList
    2004-08-24 03:59:30  bertieCbass [View]

1 to 1 of 1