Q:

what is the problem with itemdatabound event in listview?

i am getting the following error  during itemdataboundevent of a listview.
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0030: Cannot convert type 'System.Web.UI.WebControls.ListViewItemType' to 'System.Data.DataRowView'
Source Error:
   Line 91:             CheckBox chk = (CheckBox)e.Item.FindControl("chkFocusArea");
Line 92:            
Line 93:             System.Data.DataRowView rowView = (System.Data.DataRowView)e.Item.ItemType; 
Line 94:             
Line 95:         }

my code behind for itembound event is
protected void lvFocusArea_ItemDataBound(object sender, ListViewItemEventArgs e)
{
    if (e.Item.ItemType == ListViewItemType.DataItem)
    {
        CheckBox chk = (CheckBox)e.Item.FindControl("chkFocusArea");

        System.Data.DataRowView rowView = (System.Data.DataRowView)e.Item.ItemType; 

    }
}

A:

You are using the wrong property. Cast first to ListViewDataItem and use DataItem instead of ItemType:
C#
ListViewDataItem dataItem = (ListViewDataItem)e.Item;
System.Data.DataRowView rowView = (System.Data.DataRowView)dataItem.DataItem;

VB.NET
Dim dataItem As ListViewDataItem = CType(e.Item, ListViewDataItem)
Dim rowView As System.Data.DataRowView = CType(dataItem.DataItem, DataRowView)

