S
Shaun Camilleri
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.Item OrElse e.Item.ItemType =
ListItem.AlternatingItem Then
Dim ddl as DropDownList = Ctype(e.Item.FindControl("ddl"), DropDownList)
With ddl
.DataSource = ds.Tables("tbl")
.DataValueField = "Code"
.DataTextField = "Name"
.DataBind
.SelectedValue = Ctype(e.Item.DataItem, DataRow)("Code").ToString
End With
End If
If I check the DropDownList.SelectedValue 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.SelectedValue 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
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.Item OrElse e.Item.ItemType =
ListItem.AlternatingItem Then
Dim ddl as DropDownList = Ctype(e.Item.FindControl("ddl"), DropDownList)
With ddl
.DataSource = ds.Tables("tbl")
.DataValueField = "Code"
.DataTextField = "Name"
.DataBind
.SelectedValue = Ctype(e.Item.DataItem, DataRow)("Code").ToString
End With
End If
If I check the DropDownList.SelectedValue 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.SelectedValue 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