Repeater control -- Using e.Item.DataItem

G

Guest

Hello,

I have a repeater control bound to an XmlDataSource. Works great.

Now, I want to handle the ItemDataBound event--the e.Item.DataItem object in
particular. Its type is
System.Web.UI.WebControls.XmlDataSourceNodeDescriptor, which contains the
XmlNode needed to reference the data.

The problem is that _node is a private member of the
XmlDataSourceNodeDescriptor, and it is sealed, so I can't inherit it.
Doesn't it seem rather useless to embed all the data in the class, then hide
it from run-time view? It drives me crazy that I can view everything while
debugging by drilling down into the "non-public members", but you can't
programmatically access that.

Has anyone been able to use the XmlDataSourceNodeDescriptor object, or at
least reference XML nodes within the e.Item.DataItem object?

Thank you,

Eric
 
G

Guest

Found it!

I dissassembled the XmlDataSourceNodeDescriptor class and found that it
inherits from IXPathNavigable, so this code works (within the ItemDataBound
event):

XPathNavigator nav = ((IXPathNavigable)e.Item.DataItem).CreateNavigator();
myLabel.Text = nav.SelectSingleNode("myElement").Value;

I couldn't find ANY info about XmlDataSourceNodeDescriptor on MSDN, so
hopefully this helps somebody!

Eric
 
D

Dumbell

Eric,

Excellent job.

Thanks

DB

Eric said:
Found it!

I dissassembled the XmlDataSourceNodeDescriptor class and found that it
inherits from IXPathNavigable, so this code works (within the
ItemDataBound
event):

XPathNavigator nav = ((IXPathNavigable)e.Item.DataItem).CreateNavigator();
myLabel.Text = nav.SelectSingleNode("myElement").Value;

I couldn't find ANY info about XmlDataSourceNodeDescriptor on MSDN, so
hopefully this helps somebody!

Eric
 
Joined
Jun 2, 2011
Messages
2
Reaction score
0
Yessss! had to register just to thank u.. this was totally ****ing me for hte last hour !
 

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,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top