brian2k1
asked on
Using XML in DataGrid - ASP.Net 2.0 using VB.Net
I need some help getting an ASP.net 2.0 (VB) dataGrid working with an xml file.
The XML FIle is:
<gallery>
<setup path="Gallery/Irrigation/" >
<imgWidth>470</imgWidth>
<imgHeight>300</imgHeight>
<thumbWidth>50</thumbWidth >
<thumbHeight>40</thumbHeig ht>
<transitionType>fade</tran sitionType >
<thumbnailRows>1</thumbnai lRows>
<thumbPosition>bottom</thu mbPosition >
<captionPosition>top</capt ionPositio n>
<showControls>false</showC ontrols>
<backgroundColor>#FFFFFF</ background Color>
<thumbActiveColor>#3B702A< /thumbActi veColor>
<thumbRollColor>#3B702A</t humbRollCo lor>
<scaleToFit>true</scaleToF it>
<soundThumbRoll></soundThu mbRoll>
<soundThumbClick></soundTh umbClick>
<captionPosition>bottom</c aptionPosi tion>
<autoPlay>5</autoPlay>
<transitionType>iris</tran sitionType >
<stopAutoOnClick>false</st opAutoOnCl ick>
</setup>
<item>
<thumb>AA002323.JPG</thumb >
<img>AA002323.JPG</img>
</item>
<item>
<thumb>AA002325.JPG</thumb >
<img>AA002325.JPG</img>
</item>
</gallery>
in the Page_Load
Dim myDataSet As New DataSet()
myDataSet.ReadXml(Server.M apPath("Ga llery.xml" ))
dgBooks.DataSource = myDataSet
dgBooks.DataBind()
in aspx
<asp:datagrid id="dgBooks" runat="server" />
I need to display each of the images /gallery/item/img
the problem seems to be the setup section is confusing the datagrid and it skips the item nodes.
I need to show each img from the item nodes, which I will eventually make a delete button/link for a quick image management tool.
The XML FIle is:
<gallery>
<setup path="Gallery/Irrigation/"
<imgWidth>470</imgWidth>
<imgHeight>300</imgHeight>
<thumbWidth>50</thumbWidth
<thumbHeight>40</thumbHeig
<transitionType>fade</tran
<thumbnailRows>1</thumbnai
<thumbPosition>bottom</thu
<captionPosition>top</capt
<showControls>false</showC
<backgroundColor>#FFFFFF</
<thumbActiveColor>#3B702A<
<thumbRollColor>#3B702A</t
<scaleToFit>true</scaleToF
<soundThumbRoll></soundThu
<soundThumbClick></soundTh
<captionPosition>bottom</c
<autoPlay>5</autoPlay>
<transitionType>iris</tran
<stopAutoOnClick>false</st
</setup>
<item>
<thumb>AA002323.JPG</thumb
<img>AA002323.JPG</img>
</item>
<item>
<thumb>AA002325.JPG</thumb
<img>AA002325.JPG</img>
</item>
</gallery>
in the Page_Load
Dim myDataSet As New DataSet()
myDataSet.ReadXml(Server.M
dgBooks.DataSource = myDataSet
dgBooks.DataBind()
in aspx
<asp:datagrid id="dgBooks" runat="server" />
I need to display each of the images /gallery/item/img
the problem seems to be the setup section is confusing the datagrid and it skips the item nodes.
I need to show each img from the item nodes, which I will eventually make a delete button/link for a quick image management tool.
Where do you get the XML File from, can you make modifications to the Schema of the XML File?
ASKER
no modifications of the xml, it is part of a 3rd party component which I have no control over.
ok
I thought it would be better if we ould modify the schema to suite our programming needs, anyway
If you are trying to look for the missing ITEM nodes they would be a sepaerate DataTable
Debug and check how many Tables the Dataset has when you Load the XML into it.
It should have at least two (can be more) datatables, and one of them would be called "Item" and would contain the data for the Item Nodes.
Now, If just knowing where your Item Nodes have gone solves your problem then fine, otherwise please explain what are you trying to do. Is it that you want to Display the Images specified in the Item Nodes using the "Path" attribute in the Setup node, Or you just want to display the Names of the Images?
In case of the former I think you'd be better off parsing the XML and displaying, rather than use just the DataGrid
I thought it would be better if we ould modify the schema to suite our programming needs, anyway
If you are trying to look for the missing ITEM nodes they would be a sepaerate DataTable
Debug and check how many Tables the Dataset has when you Load the XML into it.
It should have at least two (can be more) datatables, and one of them would be called "Item" and would contain the data for the Item Nodes.
Now, If just knowing where your Item Nodes have gone solves your problem then fine, otherwise please explain what are you trying to do. Is it that you want to Display the Images specified in the Item Nodes using the "Path" attribute in the Setup node, Or you just want to display the Names of the Images?
In case of the former I think you'd be better off parsing the XML and displaying, rather than use just the DataGrid
ASKER
I'm making a DataGrid with pagination and command column that will include a Delete button. A thumbnail of the image will be shown along with a Delete button. When the delete button is clicked it will delete the image from the folder and rebuild the XML.
Well I think we can do that, I would try to come out with a sample
But you might need to give me some time, slightly busy now, but would surely come up with something soon
But you might need to give me some time, slightly busy now, but would surely come up with something soon
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That works great. Thanks very much for all of your hard work!
Any idea why it doesn't work with out all the code behind? I thought 2.0 was supposed to work without much code. Every time I try to work on something it takes 3x as long as ASP (with a few exceptions).
Thanks again!
Any idea why it doesn't work with out all the code behind? I thought 2.0 was supposed to work without much code. Every time I try to work on something it takes 3x as long as ASP (with a few exceptions).
Thanks again!
Well you could have got it done with fewer lines of code had the XML been formatted with DataSet in mind.
There are some Wizards/Drag Drop stuff that could have done the job.
Its a little hype when they say "No Code" pages, though I must say its pretty less amount of code still, If I compare say classic ASP or even .NET 1.1
There are some Wizards/Drag Drop stuff that could have done the job.
Its a little hype when they say "No Code" pages, though I must say its pretty less amount of code still, If I compare say classic ASP or even .NET 1.1
ASKER
I turned on Paging in code but when I click on page 2 it says "The GridView 'DGBooks' fired event PageIndexChanging which wasn't handled."
I thought paging was handled unless you specified custom pagination. Do you know why it is giving me this error?
I thought paging was handled unless you specified custom pagination. Do you know why it is giving me this error?