<p>Can anyone give me some pointers on how to display the results of an XPath query in a textbox using code (C#)?  My datascource <i>seems</i> to (re)bind correctly once the XPath query has been applied, but I cannot find how to get at the resulting data.<br /><br />
Any help would be greatly appreciated.</p>

[{'answer_id': 51490, 'author': 'd91-jal', 'author_id': 5085, 'author_profile': 'https://Stackoverflow.com/users/5085', 'pm_score': 0, 'selected': False, 'text': '<p>Some more information would be nice to have to be able to give you a decent answer. Do you have any existing code snippets you could publish here?</p>\n\n<p>The general idea is to use the XmlDataSource.XPath property as a filter on the XmlDataSource.Data property. Did you try displaying the contents of the Data prop in your textbox?</p>\n'}, {'answer_id': 51514, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>Based on a slection in a DropDownList, when the SelectedIndexChanged event fires, the XPath for an XMLDataSource object is updated:</p>\n\n<pre><code>protected void ddl_SelectedIndexChanged(object sender, EventArgs e)\n{\n    XMLds.XPath = "/controls/control[@id=\'AuthorityType\']/item[@text=\'" + ddl.SelectedValue + "\']/linkedValue";\n    XMLds.DataBind();\n}\n</code></pre>\n\n<p>The XPath string is fine, I can output and test that it is working correctly and resolving to the correct nodes. What I am having problems with, is getting at the data  that is supposedly stored in the XmlDataSource; specifically, getting the data and outputting it in a TextBox. I\'d like to be able to do this as part of the function above, i.e.<br /></p>\n\n<pre><code>protected void ddl_SelectedIndexChanged(object sender, EventArgs e)\n{\n    XMLds.XPath = "/controls/control[@id=\'AuthorityType\']/item[@text=\'" + ddl.SelectedValue + "\']/linkedValue";\n    XMLds.DataBind();\n    myTextBox.Text = &lt;FieldFromXMLDataSource&gt;;\n}\n</code></pre>\n\n<p>Thank you for your time.</p>\n'}, {'answer_id': 51698, 'author': 'd91-jal', 'author_id': 5085, 'author_profile': 'https://Stackoverflow.com/users/5085', 'pm_score': 1, 'selected': False, 'text': '<p>XMLDataSource is designed to be used with data-bound controls. ASP.NET\'s TextBox is not a data-bound control. So to accomplish what you want you either have to find a textbox control with data binding or display the result in some other way. </p>\n\n<p>For example, you could use a <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater.aspx" rel="nofollow noreferrer">Repeater control</a> and create your own rendering template for it. </p>\n\n<pre><code>&lt;asp:Repeater id="Repeater1" runat="server" datasource="XMLds"&gt;\n  &lt;ItemTemplate&gt;\n    &lt;input type="text" value="&lt;%# XPath("&lt;path to display field&gt;")%&gt;" /&gt;\n  &lt;/ItemTemplate&gt;\n&lt;/asp:Repeater&gt;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/51429', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']