Hello,
I have a dropdown list within a listview 'EditItemTemplate' and 'InsertItemTemplate" which I am trying to populate from the database with code behind with ItetmDataBound event. Problem is I am getting NullException when I use this code which works fine for ItemTemplate.
<asp:DropDownList ID="ddlItemtList" runat="server">
<asp:ListItem Selected="True" Text="--Select Item--" Value="0" />
</asp:DropDownList>
If Page.IsPostBack Then
If e.Item.ItemType = ListViewItemType.DataItem Then
Dim ddl As DropDownList = DirectCast(e.Item.FindControl("ddlItemList"), DropDownList)
If ddl Is Nothing Then
MsgBox("Nothing")
Else
MsgBox(ddl.SelectedItem.Text)
End If
End If
End If
I get the "Nothing" as output whever I press edit. How do I access the DropDownList withint he Listview?Thank youi.