DataItem!!

  • Thread starter Thread starter Adam J Knight
  • Start date Start date
A

Adam J Knight

Hi all,

I have a datagrid which is bound to a DATA READER object.

During its item bound event i am trying to retrieve a particular value from
the dataitem property.

Code:

public void dgEnrollments_ItemBound(object sender, DataGridItemEventArgs e)
{
Response.Write(((DataRowView)e.Item.DataItem).Row.ItemArray[2].ToString());
//line causing errror.
}


Unfortunately i am getting the following error.

Unable to cast object of type 'System.Data.Common.DbDataRecord' to type
'System.Data.DataRowView'.

Anyone know how to fix this??

Cheers,
Adam
 
Adam,

DataReaders are not DataTables. Their DataItems are of type DbDataRecord.
You have to work with this type properties.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top