Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8670841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:48:10+00:00 2026-06-12T18:48:10+00:00

In my application, I defined an XMLDataSource in the ASPX: <asp:XmlDataSource ID=XmlThickness runat=server DataFile=~/XML/Data/products.xml

  • 0

In my application, I defined an XMLDataSource in the ASPX:

<asp:XmlDataSource ID="XmlThickness" runat="server"
    DataFile="~/XML/Data/products.xml" EnableCaching="False" 
    EnableViewState="False" 
    ></asp:XmlDataSource>

This datasource feeds a grid.

In my code, I set the XPath at a specific point in a specific function, and then issue a new DataBound() on the XMLDataSource, causing the grid to update:

XmlThickness.XPath = "/Item[@label='" + tvwMaterials.SelectedNode.Text + "']/Thickness/Thick";
XmlThickness.DataBind();

All of this works a charm, but when I attempt to read out the XPAth from within a different function, I receive an error message.

XmlNode thick = myDataSource.SelectSingleNode(XmlThickness.XPath.ToString());

Debugging shows the XPath expression actually is empty.

I attempted to move the creation of the DataSource to code, and only then setting the DataSourceID of the grid, but that did not work.

Prior to trying this, I defined a default XPath in the XMLDataSource definition, and at that point, the XMLNode thick line returned this default string.

I’m a bit confused as to why the XPath is not retained at the XMLDataSource afdter I explicitly set it in the earlier function. Could someone shed some light on this for me, please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:48:11+00:00Added an answer on June 12, 2026 at 6:48 pm

    XmlDataSource nodes are not stored in the viewState, like most datasource controls. You should call databind only once, and the control should rebuild itself automatically on postback. I case you want to change datasource, you can save the selectedNode form the treeviw in Viewstate, and on postback, change your dataSource, by retrieving the value from viewState, before you assign the DataSourceID and call DataBind().
    Have a look here:

    http://forums.asp.net/t/1437802.aspx/1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an application that contains some buttons defined via layout.xml like this
In an ASP.MVC application, I have a function defined in my _ViewStart.cshtml like this:
I have some Shared Preferences in my application defined in an XML file. They
I have pretty weird question. In my ASP.NET MVC application I defined 1 Timer
I'm trying out Ember.js with ember-data, and I have the following application defined: window.App
My application uses several threads with well-defined names (i.e. not a thread pool with
In my MVC application I have a default route defined: routes.MapRoute( Default, // Route
In a large Application is there any way to distinguish user-defined classes with built-in
In my application I have a class which has properties of user-defined types like
We have an old application where the relationship is defined as below: class Practice

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.