Repeater Data
-
I have placed a DropDownList within a Repeater and I am having troubles to set correct value to DropDownlist. I tried following code
Private Sub rptDep_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptDep.ItemDataBound Dim myList As DropDownList = CType(e.Item.FindControl("cboProjectRule"), DropDownList) ' Dim dr As DataRow = CType(e.Item.DataItem.Row, DataRow) ' some other code hier end sub
but commented line does not work because of option Strict = On. Any Suggestions? Marek -
I have placed a DropDownList within a Repeater and I am having troubles to set correct value to DropDownlist. I tried following code
Private Sub rptDep_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptDep.ItemDataBound Dim myList As DropDownList = CType(e.Item.FindControl("cboProjectRule"), DropDownList) ' Dim dr As DataRow = CType(e.Item.DataItem.Row, DataRow) ' some other code hier end sub
but commented line does not work because of option Strict = On. Any Suggestions? Marek -
Hi there, Two options here: + Turn off the
Strict
attribute. + Cast theDataItem
property from theObject
type to a real data type:Dim dr as DataRow = CType(e.Item.DataItem, DataRowView).Row
Hi Turning Strict on was not an option, but second proposal was exactly I was looking for. Thanks a lot Marek