I have a EditItemTemplate in a datagrid that contain a
dropdown that bound to a dataset. In that grid I have a
ItemCreated to handle the dropdow created. But the
selected item is not work. I tried 3 ways. see code.
Thanks.
Private Sub dgFundList_ItemCreated(ByVal sender As
Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgFundList.ItemCreated
Dim elemType As ListItemType
elemType = e.Item.ItemType
If elemType = ListItemType.EditItem Then
Dim ddlUserName As DropDownList = CType
(e.Item.FindControl("ddlUserName"), DropDownList)
ddlUserName.DataSource = dtUser
ddlUserName.DataTextField = "FullName"
ddlUserName.DataValueField = "UserID"
ddlUserName.DataBind()
'ddlUserName.SelectedItem.Selected = False
'ddlUserName.Items.FindByValue
("11111").Selected = true
'ddlUserName.Items.FindByText
("mytext").Selected = True
ddlUserName.SelectedIndex =
ddlUserName.Items.IndexOf(ddlUserName.Items.FindBy Value
("11111"))
End If