D
David C
I need to populate a DropDownList when going into Insert mode on a ListView.
I have done this several times in a GridView or FormView but cannot get it
to work in a ListView. Below is my ItemDatabound code and the control named
ddlExpenseID is not getting filled. Can anyone help?
p.s. i need in both Insert and Edit. Thanks.
David
Protected Sub lvIncExpTrans_ItemDataBound(ByVal sender As Object, ByVal
e As System.Web.UI.WebControls.ListViewItemEventArgs) Handles
lvIncExpTrans.ItemDataBound
Dim tb As TextBox
Dim ddl As DropDownList
If e.Item.ItemType = ListViewItemType.DataItem Then
If Not e.Item.FindControl("ddlExpenseID") Is Nothing Then
' In edit or insert so get values for DropDownLists
' Get contents of dropdownlists and populate
ddl = CType(e.Item.FindControl("ddlExpenseID"),
DropDownList)
ddl.DataSource = LookupClass.GetExpenseTypes()
ddl.DataValueField = "ExpenseID"
ddl.DataTextField = "Expense"
ddl.DataBind()
End If
End If
End Sub
I have done this several times in a GridView or FormView but cannot get it
to work in a ListView. Below is my ItemDatabound code and the control named
ddlExpenseID is not getting filled. Can anyone help?
p.s. i need in both Insert and Edit. Thanks.
David
Protected Sub lvIncExpTrans_ItemDataBound(ByVal sender As Object, ByVal
e As System.Web.UI.WebControls.ListViewItemEventArgs) Handles
lvIncExpTrans.ItemDataBound
Dim tb As TextBox
Dim ddl As DropDownList
If e.Item.ItemType = ListViewItemType.DataItem Then
If Not e.Item.FindControl("ddlExpenseID") Is Nothing Then
' In edit or insert so get values for DropDownLists
' Get contents of dropdownlists and populate
ddl = CType(e.Item.FindControl("ddlExpenseID"),
DropDownList)
ddl.DataSource = LookupClass.GetExpenseTypes()
ddl.DataValueField = "ExpenseID"
ddl.DataTextField = "Expense"
ddl.DataBind()
End If
End If
End Sub