Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 19, 2011 02:59 AM by kurniadi
May 16, 2008 08:03 PM|LINK
I am semi new to XML This is done in VB
I am having trouble getting a datagrid to refresh data after the initial load of data from an XMLDataSource.
I have a textBox where I enter some information anda Button to send it to get an XML response file
I am making a request for an xml file.
Dim srResponse As
I then bind the data to an XMLdatasource (XMLResponse)(It's all formatted with a transform file as I need it)
XMLResponse.Data = OrderResp
I then Bind the XMLDatasource to my Gridview
gvorders.DataSource = XMLResponse
The first time I enter a value and submit the data everything works fine.
The second time I submit a new value the result Text field changes with new data but the Gridview stays the same.
I have tried..
Setting the Gridviews EnableViewState to FALSE
Clearing the datasource (on both the XMLDataSource and the datagrid) before the binding
gvorders.DataSource = ""
gvorders.DataSource = XMLResponse
I created a texfile (Trace file) that adds a timestamp between every transaction to see if it was being skipped for some reason and the trace file executes just fine.
I then started a new page and kept the basic elements and the gridview will only update once.
I also found that If I run a query a second time the text value will change correctly but the gridview keeps the old data. I then open the page in an editor. add a space somewhere on the design page and save (so that it will recompile the page) the new data
will then load in the gridview. I then do another query and the text changes but the grid stays the same.
I have to say that I am completely at a loss.....Is there something that I'm doing wrong? When I make a call for an XML file does all processing stop until it gets an answer? I thought that maybe the code contined while the page was waiting on the response
but if that was the case the text file would not update as well because I update that before I do the Gridview bid.
I ultimately want to save this to a database in a batch mode but if the data doesn't refresh I will be writing the same data over and over again.
Any help wpuld be appreciated
May 17, 2008 07:37 AM|LINK
The XmlDataSource, unlike any other datasource (ObjectDataSource, LinqDataSource, etc) has caching enabled by default. And not only that, the cache duration is set to 0 (infinite), also by default. It's pretty stupid, but a quite common issue with it.
When you create your XmlDataSource you have to disable caching.
XmlDataSource xds = new XmlDataSource();
That should do the trick.
May 17, 2008 12:54 PM|LINK
Sub BindGrid(ByVal strRss As String, ByVal oGrid _
As GridView, ByVal iTable As Integer)
Dim oDs As New Data.DataSet
oGrid.DataSource = oDs.Tables(iTable)
May 17, 2008 05:28 PM|LINK
How does a DataSet deal with hierarchical data like xml? I never use them because they're such big ugly objects. Far too much overhead.
Just keep your code the same as it is, but add the xds.EnableCaching=false and all will be well.
May 19, 2008 12:52 PM|LINK
I assumed that it was a cacheing issue but I guess I was stumped because I was loading in new data to the XMLdatasource which I would assume would clear out the cache or force a reload since the data had changed. I think I also tried setting the text control
to the datasource.data and it changed but the grid did not. I will try your suggestion and hopefull this will solve my problem.
I'm doing all of this because I can't find an easier way to download an XML file and pull it into a database with all of the elements separated into a table not just the xml in one field. If anyone has an easier way to do this i'm all ears.
May 20, 2008 03:29 AM|LINK
Not sure what database you are using, but I send lots of xml to SQL 2005, which has a great xml datatype. Then I can parse the xml in my stored procedure and put it where it needs to go or store the entire xml string into an xml column of a table for later
Dec 25, 2009 09:23 AM|LINK
Thanks Dude. u saved me.
Dec 30, 2009 03:23 PM|LINK
I am trying to update my XML file that is bound to the gridview but am not able to do it. I read on the web that Gridview doesn't automatically update the XMLDatasource and that we should write our own event handlers to updat it. I can get the selected
row from the grid, but how can I update the XML file with this data? How would I know which node corresponds to the selected row in the grid. Would some one be able to help me? Thanks a bunch for your help, in advace.
Jan 04, 2010 07:01 AM|LINK
even i am facing the similar problem. can some one pls help me soon.
i have a XMLDataSource for which i mentioned the datafile to 'MyXml'.
In my page i have a textbox and a button 'add' for adding the text to the xml and display the same in the datagrid.
While displaying the xml data in the grid i used
grdDetails.DataSource = XmlDataSource1;
but wen i click that add button the data is getting updated in xml file and i can see that, but in the datagrid it is not getting updated.
pls help soon.thanx in advance.
Jan 04, 2010 07:03 AM|LINK
i tried datasource caching with false...it didnt help me...
so please help me .....