Preselecting Item in DropDown List
This works from Microsoft.
Code:
Private Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataList1.ItemDataBound
If e.Item.ItemType = ListItemType.EditItem Then
Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)
Dim currentgenre As String = CType(drv("TypeName"), String)' Name of the item you are looking for
Dim ddl As DropDownList
ddl = CType(e.Item.FindControl("dwnType"), DropDownList)' Name of the control you are looking for
ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Items.FindByText(currentgenre))' Here is where it preselects the control
End If
End Sub