I am trying to get the bound values from a row in a ListItem. I have a button on each row that when clicked will perform a task (sending an email message to the person who's name and email address is in that listitem row. So, I have an event handler tied to the listview, and I am trying to get to the underlying datarowview to extract the data items.
Here's what I have in the event handler:
Protected Sub lvUsers_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewCommandEventArgs) Handles lvUsers.ItemCommand
Dim diCurrentUser As ListViewDataItem = CType(e.Item, ListViewDataItem)
Dim drCurrentRow As DataRowView = CType(diCurrentUser.DataItem, DataRowView)
Select Case e.CommandName
Case "Email"
Dim strEmailAddress As String = drCurrentRow("contact_email").ToString.Trim
Dim strUserName As String = drCurrentRow("login").ToString.Trim
Dim strUserID As String = drCurrentRow("username").ToString.Trim
Dim strPassword As String = drCurrentRow("password").ToString.Trim
Now, it fails at the line where I am trying to access the contact_email element in the DataRowView object.
What an I doing wrong?
Thanks