C
Crazy Cat
HI,
I have a dropdownlist nested in a datalist.
In the datalist's ItemDataBound event I populate the dropdownlist and
set it's SelectedValue.
I am finding that instead of each DropDownList being set to
independent values all the dropdownlists' selectedvalue settings are
being set to the value of the last dropdownlist set. Here's the code
--
Protected Sub dlIncentives_ItemDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles
dlIncentives.ItemDataBound
If Not IsPostBack Then
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType
= ListItemType.AlternatingItem Then
Dim ddlImportance As DropDownList =
e.Item.FindControl("ddlImportance")
For Each item As ListItem In Importances
ddlImportance.Items.Add(item)
Next
ddlImportance.SelectedValue = CType(e.Item.DataItem,
DataRowView).Row.Item("IncImp_ID").ToString
End If
End If
End Sub
Any idea what I could be doing wrong? I've set a breakpoint and can
see that different values are being set for the SelectedValue, but
when the page is displayed only the last value set is applied to the
SelectedValue for all the dropdownlists.
Thanks
I have a dropdownlist nested in a datalist.
In the datalist's ItemDataBound event I populate the dropdownlist and
set it's SelectedValue.
I am finding that instead of each DropDownList being set to
independent values all the dropdownlists' selectedvalue settings are
being set to the value of the last dropdownlist set. Here's the code
--
Protected Sub dlIncentives_ItemDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles
dlIncentives.ItemDataBound
If Not IsPostBack Then
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType
= ListItemType.AlternatingItem Then
Dim ddlImportance As DropDownList =
e.Item.FindControl("ddlImportance")
For Each item As ListItem In Importances
ddlImportance.Items.Add(item)
Next
ddlImportance.SelectedValue = CType(e.Item.DataItem,
DataRowView).Row.Item("IncImp_ID").ToString
End If
End If
End Sub
Any idea what I could be doing wrong? I've set a breakpoint and can
see that different values are being set for the SelectedValue, but
when the page is displayed only the last value set is applied to the
SelectedValue for all the dropdownlists.
Thanks