B
Big Dave
I know it's been asked a million times before, but I still can't seem to
find an answer that works.
I've got a dropdown list in the footer template of a datagrid. The
dropdown list databinds, but I can't seem to add a blank item to the top
of the dropdown list.
I've tried using the code to add this by placing it in both the
page_load and the datagrid.itemDataBound event, but neither seems to
work. I've also referenced the control by
ctype(e.items.findControl("ddlName"), Dropdownlist) and by it's actual
id. I've tried both the .add and .insert method's of the
dropdownlist.items collection.
I've been able to get this to work outside of the datagrid, but can't
seem to get it to work inside the datagrid. Any help would be greatly
appreciated!!!
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
If e.Item.ItemType = ListItemType.Footer Then
'option 1 - doesn't work
CType(e.Item.FindControl("cmbAddFeatureType2"),
DropDownList).Items.Insert(0, New ListItem("Select", ""))
'option 2 - doesn't work
Me.cmbAddFeatureType2.Items.Insert(0, New ListItem("Select",
""))
End If
End Sub
Big Dave
find an answer that works.
I've got a dropdown list in the footer template of a datagrid. The
dropdown list databinds, but I can't seem to add a blank item to the top
of the dropdown list.
I've tried using the code to add this by placing it in both the
page_load and the datagrid.itemDataBound event, but neither seems to
work. I've also referenced the control by
ctype(e.items.findControl("ddlName"), Dropdownlist) and by it's actual
id. I've tried both the .add and .insert method's of the
dropdownlist.items collection.
I've been able to get this to work outside of the datagrid, but can't
seem to get it to work inside the datagrid. Any help would be greatly
appreciated!!!
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
If e.Item.ItemType = ListItemType.Footer Then
'option 1 - doesn't work
CType(e.Item.FindControl("cmbAddFeatureType2"),
DropDownList).Items.Insert(0, New ListItem("Select", ""))
'option 2 - doesn't work
Me.cmbAddFeatureType2.Items.Insert(0, New ListItem("Select",
""))
End If
End Sub
Big Dave