Link to home
Start Free TrialLog in
Avatar of brian2k1
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</thumbHeight>
    <transitionType>fade</transitionType>
    <thumbnailRows>1</thumbnailRows>
    <thumbPosition>bottom</thumbPosition>
    <captionPosition>top</captionPosition>
    <showControls>false</showControls>
    <backgroundColor>#FFFFFF</backgroundColor>
    <thumbActiveColor>#3B702A</thumbActiveColor>
    <thumbRollColor>#3B702A</thumbRollColor>
    <scaleToFit>true</scaleToFit>
    <soundThumbRoll></soundThumbRoll>
    <soundThumbClick></soundThumbClick>
    <captionPosition>bottom</captionPosition>
    <autoPlay>5</autoPlay>
    <transitionType>iris</transitionType>
    <stopAutoOnClick>false</stopAutoOnClick>
  </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.MapPath("Gallery.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.
Avatar of arif_eqbal
arif_eqbal

Where do you get the XML File from, can you make modifications to the Schema of the XML File?
Avatar of brian2k1

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'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
ASKER CERTIFIED SOLUTION
Avatar of arif_eqbal
arif_eqbal

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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!
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

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?