DataItem!!

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
 
E

Eliyahu Goldin

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top