Results 1 to 2 of 2

Thread: Preselecting Item in DropDown List

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Thumbs up 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

  2. #2
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Toronto, Ontario, Canada
    Posts
    275
    thanx..do you have the link

Posting Permissions

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



Click Here to Expand Forum to Full Width