dropdown list can't selected.

L

lucy

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.FindByValue
("11111"))
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top