Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. XMLDataSource.Data not binding right

XMLDataSource.Data not binding right

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netwpfwcfdesign
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Yisman2
    wrote on last edited by
    #1

    Hello Everybody. Its my first time using the CP forum. though I use the articles all the time... :) I have some code that builds an XML document for each user that logs in. This xml doc should become the datasource for the navigation system. I do not use the built-in membership system, but rather have my own "Users" table and do my own authentication etc. The XML Document is stored in a strongly-typed Session variable (as a public property in a class module). The property name is "CurrentMap" The problem is that setting XMLDataSource.Data to the xml snippet just doesnt work. when i log in i always see the menus belonging to the previous user which logged in. Only when continuing in the site do i see the menu items based on the current users sitemap. For testing i used the CurrentMap.Save method to save the doc to disk, and the doc is 100% correct, exactly according to my code. the problem is only on the home page, feels like asp.net is kindly doing some caching which id like to turn off. It may also be in regard to the events that I use to bind the datasource to the xmldoc, and I used quite a few of them. But maybe im just not using the right one... :sigh: This is happening on the code behind in a Master page in asp.net 3.5. here is the entire relevant codebehind file for the master page:

    Partial Class IMaster
        Inherits System.Web.UI.MasterPage
    
        Protected Sub Page\_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DataBinding
            CheckUser()
            xdsSiteMap.DataFile = ""
            xdsSiteMap.Data = CurrentMap.OuterXml
        End Sub
    
       Protected Sub Page\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
           CheckUser()
           xdsSiteMap.DataFile = ""
           xdsSiteMap.Data = CurrentMap.OuterXml
           xdsSiteMap.DataBind()
           MainMenu.DataBind()
       End Sub
    
        Protected Sub lkbLogout\_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lkbLogout.Click
           ClearUser()
           CheckUser()
       End Sub
    
       Protected Sub xdsSiteMap\_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles xdsSiteMap.DataBinding
           xdsSiteMap.DataFile = ""
           xdsSiteMap.Data = CurrentMap.OuterXml
       End Sub
    

    End Class

    Here is the aspx of the master page

                <td colspan="2">
                    <div id="MainNav" class="MainNav">
                        <
    
    T L 2 Replies Last reply
    0
    • Y Yisman2

      Hello Everybody. Its my first time using the CP forum. though I use the articles all the time... :) I have some code that builds an XML document for each user that logs in. This xml doc should become the datasource for the navigation system. I do not use the built-in membership system, but rather have my own "Users" table and do my own authentication etc. The XML Document is stored in a strongly-typed Session variable (as a public property in a class module). The property name is "CurrentMap" The problem is that setting XMLDataSource.Data to the xml snippet just doesnt work. when i log in i always see the menus belonging to the previous user which logged in. Only when continuing in the site do i see the menu items based on the current users sitemap. For testing i used the CurrentMap.Save method to save the doc to disk, and the doc is 100% correct, exactly according to my code. the problem is only on the home page, feels like asp.net is kindly doing some caching which id like to turn off. It may also be in regard to the events that I use to bind the datasource to the xmldoc, and I used quite a few of them. But maybe im just not using the right one... :sigh: This is happening on the code behind in a Master page in asp.net 3.5. here is the entire relevant codebehind file for the master page:

      Partial Class IMaster
          Inherits System.Web.UI.MasterPage
      
          Protected Sub Page\_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DataBinding
              CheckUser()
              xdsSiteMap.DataFile = ""
              xdsSiteMap.Data = CurrentMap.OuterXml
          End Sub
      
         Protected Sub Page\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
             CheckUser()
             xdsSiteMap.DataFile = ""
             xdsSiteMap.Data = CurrentMap.OuterXml
             xdsSiteMap.DataBind()
             MainMenu.DataBind()
         End Sub
      
          Protected Sub lkbLogout\_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lkbLogout.Click
             ClearUser()
             CheckUser()
         End Sub
      
         Protected Sub xdsSiteMap\_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles xdsSiteMap.DataBinding
             xdsSiteMap.DataFile = ""
             xdsSiteMap.Data = CurrentMap.OuterXml
         End Sub
      

      End Class

      Here is the aspx of the master page

                  <td colspan="2">
                      <div id="MainNav" class="MainNav">
                          <
      
      T Offline
      T Offline
      ToddHileHoffer
      wrote on last edited by
      #2

      Yes. Add Page_PreRender method to the master page. This is the later in the page's life cycle than page_load. Move the databind() call to that method, see if you get the current user.

      I didn't get any requirements for the signature

      Y 1 Reply Last reply
      0
      • T ToddHileHoffer

        Yes. Add Page_PreRender method to the master page. This is the later in the page's life cycle than page_load. Move the databind() call to that method, see if you get the current user.

        I didn't get any requirements for the signature

        Y Offline
        Y Offline
        Yisman2
        wrote on last edited by
        #3

        Hi Thank you ToddHileHoffer, I did exactly that, but the problem remains. on the landing page i get an old map. here is the current masterpage code

        Protected Sub lkbLogout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lkbLogout.Click
        ClearUser()
        CheckUser()
        End Sub

        Protected Sub Page\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            CheckUser()
        End Sub
        
        Protected Sub Page\_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
            xdsSiteMap.DataFile = ""
            xdsSiteMap.Data = CurrentMap.OuterXml
            MainMenu.DataBind()
        End Sub
        

        Please reply, i cant figure this out...

        T 1 Reply Last reply
        0
        • Y Yisman2

          Hi Thank you ToddHileHoffer, I did exactly that, but the problem remains. on the landing page i get an old map. here is the current masterpage code

          Protected Sub lkbLogout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lkbLogout.Click
          ClearUser()
          CheckUser()
          End Sub

          Protected Sub Page\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
              CheckUser()
          End Sub
          
          Protected Sub Page\_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
              xdsSiteMap.DataFile = ""
              xdsSiteMap.Data = CurrentMap.OuterXml
              MainMenu.DataBind()
          End Sub
          

          Please reply, i cant figure this out...

          T Offline
          T Offline
          ToddHileHoffer
          wrote on last edited by
          #4

          I'm sorry your page isn't working. Where are you setting the datasource for the MainMenu? Why don't you call xdsSiteMap.Databind() instead of MainMenu.Databind()? Can you debug the page and set a break point on your menu or site map and verify that the data source in the PreRender method does not match the data when the page is rendered? Another question is why are you calling CheckUser() twice? In the code above you would call CheckUser in the pageload and then agin on lkbLogout.Click(). Maybe you want to use if(!postback) in your pageload.

          I didn't get any requirements for the signature

          Y 1 Reply Last reply
          0
          • T ToddHileHoffer

            I'm sorry your page isn't working. Where are you setting the datasource for the MainMenu? Why don't you call xdsSiteMap.Databind() instead of MainMenu.Databind()? Can you debug the page and set a break point on your menu or site map and verify that the data source in the PreRender method does not match the data when the page is rendered? Another question is why are you calling CheckUser() twice? In the code above you would call CheckUser in the pageload and then agin on lkbLogout.Click(). Maybe you want to use if(!postback) in your pageload.

            I didn't get any requirements for the signature

            Y Offline
            Y Offline
            Yisman2
            wrote on last edited by
            #5

            hi thanks for your reply in the end, my assumption was correct, the xds has an attribute called enavlecaching, i turned that off and all is good. thank you for your time and interest, it was a pleasure discussing this with you.:thumbsup:

            J 1 Reply Last reply
            0
            • Y Yisman2

              Hello Everybody. Its my first time using the CP forum. though I use the articles all the time... :) I have some code that builds an XML document for each user that logs in. This xml doc should become the datasource for the navigation system. I do not use the built-in membership system, but rather have my own "Users" table and do my own authentication etc. The XML Document is stored in a strongly-typed Session variable (as a public property in a class module). The property name is "CurrentMap" The problem is that setting XMLDataSource.Data to the xml snippet just doesnt work. when i log in i always see the menus belonging to the previous user which logged in. Only when continuing in the site do i see the menu items based on the current users sitemap. For testing i used the CurrentMap.Save method to save the doc to disk, and the doc is 100% correct, exactly according to my code. the problem is only on the home page, feels like asp.net is kindly doing some caching which id like to turn off. It may also be in regard to the events that I use to bind the datasource to the xmldoc, and I used quite a few of them. But maybe im just not using the right one... :sigh: This is happening on the code behind in a Master page in asp.net 3.5. here is the entire relevant codebehind file for the master page:

              Partial Class IMaster
                  Inherits System.Web.UI.MasterPage
              
                  Protected Sub Page\_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DataBinding
                      CheckUser()
                      xdsSiteMap.DataFile = ""
                      xdsSiteMap.Data = CurrentMap.OuterXml
                  End Sub
              
                 Protected Sub Page\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
                     CheckUser()
                     xdsSiteMap.DataFile = ""
                     xdsSiteMap.Data = CurrentMap.OuterXml
                     xdsSiteMap.DataBind()
                     MainMenu.DataBind()
                 End Sub
              
                  Protected Sub lkbLogout\_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lkbLogout.Click
                     ClearUser()
                     CheckUser()
                 End Sub
              
                 Protected Sub xdsSiteMap\_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles xdsSiteMap.DataBinding
                     xdsSiteMap.DataFile = ""
                     xdsSiteMap.Data = CurrentMap.OuterXml
                 End Sub
              

              End Class

              Here is the aspx of the master page

                          <td colspan="2">
                              <div id="MainNav" class="MainNav">
                                  <
              
              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Hi try EnableCaching="false" on XmlDataSource control

              1 Reply Last reply
              0
              • Y Yisman2

                hi thanks for your reply in the end, my assumption was correct, the xds has an attribute called enavlecaching, i turned that off and all is good. thank you for your time and interest, it was a pleasure discussing this with you.:thumbsup:

                J Offline
                J Offline
                Jim_Gray
                wrote on last edited by
                #7

                Thank you. I've been fussing with my code, on and off, for the last few days trying to figure out why I couldn't get my string output of XML data to bind to my ListView object in .Net 3.5. I found the "onPreRender" statement in another article but a separate test datalist object bound fine in the "OnLoad" event. Turning the caching off was exactly what I needed- thanks. :laugh:

                Y 1 Reply Last reply
                0
                • J Jim_Gray

                  Thank you. I've been fussing with my code, on and off, for the last few days trying to figure out why I couldn't get my string output of XML data to bind to my ListView object in .Net 3.5. I found the "onPreRender" statement in another article but a separate test datalist object bound fine in the "OnLoad" event. Turning the caching off was exactly what I needed- thanks. :laugh:

                  Y Offline
                  Y Offline
                  Yisman2
                  wrote on last edited by
                  #8

                  glad to be of help :)

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups