473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

DataItem!!

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
Jan 17 '06 #1
1 1165
Adam,

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

Eliyahu

"Adam J Knight" <ad**********@optusnet.com.au> wrote in message
news:e8**************@TK2MSFTNGP09.phx.gbl...
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

Jan 17 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: az bij | last post by:
Hi, I have a dataset bound to a repeater and want to place some logic in my ascx file. I want to display an image link if and only if an image is available. I have tried without success...
1
by: Mike P | last post by:
I'm having trouble with C# syntax for Container.DataItem. This is the VB version. CAn anybody help me out with the syntax? <asp:DataList runat="server" id="dlResults" Font-Name="Verdana"...
2
by: Tom Lee | last post by:
Hi all, I have the following problem and I cannot solve it. If anyone can help me solve this problem. I use the following code <%#DataBinder.Eval(Container.DataItem, "Property")%> to display...
2
by: ric carrasquilla | last post by:
first, thx to martin for helping me with my initial post. im a newbie and appreciate the help. if someone can help me with another question, please do. i have a repeater pulling job...
5
by: bg | last post by:
Hi! How do I check if "date" exists before using that code? I've built a RSSreader and sometimes there's a date in it and sometimes not. How can I check if it exists to avoid crash...
1
by: Zenobia | last post by:
How do I bind an array, arrayList or even a stack to a repeater containing hyperlinks. The data structure (array, arrayList or even a stack) has dates in ISO format "YYYY-MM-DD". The repeated...
7
by: Mirek Endys | last post by:
Hello, the problem I have now, is: Im binding generic collection based on List<iDB2SQLTransferItem> // iDB2SQLTransferItem is my class // into WebCOntrol DataList. But the DataItem of the...
15
by: Laser Lu | last post by:
Hi, all, I was tangled by the DataGridItem.DataItem property. I tried to invoke that property to get and display the contents that was bound to the currently selected row. However, an exception...
1
by: Nathan Sokalski | last post by:
I need to access one of the columns from the current DataItem in the ItemCommand event, which I call using EventBubbling with a DataList and Button control. The code I tried to use to access the...
3
by: alberthung01 | last post by:
Hi all, I try to use Container.DataItem() in my DataGrid's ItemTemplate. Somewhere it works fine. eg.<input type=checkbox id='cb_select_<%# Container.DataItem("TAG_ID") %>' value='<%#...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.