Hi all,
I am creating a DropDownList in a RepeaterControl . After the Repeater is
DataBound in the ItemCreated event (of the Repeater) I bind the DropDownList
to a Table and then try to select one of its value. Here is the code:
If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItem.Altern atingItem Then
Dim ddl as DropDownList = Ctype(e.Item.Fi ndControl("ddl" ), DropDownList)
With ddl
.DataSource = ds.Tables("tbl" )
.DataValueField = "Code"
.DataTextField = "Name"
.DataBind
.SelectedValue = Ctype(e.Item.Da taItem, DataRow)("Code" ).ToString
End With
End If
If I check the DropDownList.Se lectedValue while I'm still in the above code
the SelectedValue is correctly set, but when i finally view the resulting
page all the DropDownLists controls that the Repeater has the first Item
selected... Apart from DropDownList.Se lectedValue i tried to use other
methods (i.e. .SelectedIndex) but the result is the same, the first value of
the DropDown is selected...
Thanks for you help
Shaun