Repeater control -- Using e.Item.DataItem

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 

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