Calling Repeater DataItems

Q

qwerty

I have tried to call the Repeater´s item´s DataItem example from Page´s
functions. I have put to the Repeater ID and Name got from the database.

I have tried following:
CType(Repeater(index).DataItem, DataRowView)("ID")

DataBinder.Eval(Repeater(index).DataItem, "ID")

First get me "NullReferenceException" and second zero length string.
 
Q

qwerty

qwerty said:
I have tried to call the Repeater´s item´s DataItem example from Page´s
functions. I have put to the Repeater ID and Name got from the database.

I have tried following:
CType(Repeater(index).DataItem, DataRowView)("ID")

DataBinder.Eval(Repeater(index).DataItem, "ID")

First get me "NullReferenceException" and second zero length string.
Any help?
 
Q

qwerty

Scott said:
Hi qwerty:

Does this happen after you've set a DataSource and called DataBind?
Yes. Repeater.Count gets me the number of items so they exist there.
 
S

Scott Allen

In doing some testing it appears to me the DataItem property is only
valid during the act of data binding. If you add an event handler for
the ItemDataBound event you can dig out the DataRowView, otherwise I
think you'll have to dig into the control hierarchy of the
RepeaterItem to find the string put in place during binding.

Make any sense? Does that help your solution?
 
Q

qwerty

Scott said:
In doing some testing it appears to me the DataItem property is only
valid during the act of data binding. If you add an event handler for
the ItemDataBound event you can dig out the DataRowView, otherwise I
think you'll have to dig into the control hierarchy of the
RepeaterItem to find the string put in place during binding.

Make any sense? Does that help your solution?
Yes, thanks for testing. In my mind didn't came trying events.

I can do what i wanted with ItemDataBound-event using condition
statement to define what item I want to handle.

As a last alternative I would used html controls tag´s attributes.
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top