473,804 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using XML with ASP.NET

I'm trying to add XML to my my ASP.NET project and have it read by
the
gridview control or even the telerik radgrid control either way, it
doesn't work. I get an error about not finding and bindable
properties. Here's a sample of it:

<?xml version="1.0" encoding="UTF-8" standalone="yes "?>
<dealers xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
<dealer_item id="93">
<name>Auburn Harley Davidson</name>
<street>12075 Locksley Ln</street>
<city>Auburn</city>
<state>Californ ia</state>
<zip>95602</zip>
<phone>53088571 61</phone>
</dealer_item>
<dealer_item id="101">
<name>Backroa ds Custom Cycle</name>
<street>7939 A E 11th ST</street>
<city>Tracy</city>
<state>Californ ia</state>
<zip>95304</zip>
<phone>20983907 56</phone>
</dealer_item>
</dealers>
I even tried adding an XSL document to see if that would do the
trick:
<?xml version="1.0" ?>
<xsl:styleshe et version="1.0" xmlns:xsl="http ://www.w3.org/1999/XSL/
Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<table border="2" bgcolor="yellow ">
<tr>
<td>Title: <xsl:value-of select="dealer_ item"/>
</td>
</tr>
<tr><th>Deale r</th><th>Street</th><th>City</th><th>State</
th><th>Zip</
th><th>Phone #</th></tr>
<xsl:for-each select="dealers/dealer_item">
<tr><td><xsl:va lue-of select="dealer_ item"/></td><td><xsl:val ue-
of
select="street"/></td><td><xsl:val ue-of select="city"/></
td><td><xsl:val ue-of select="state"/></td><td><xsl:val ue-of
select="zip"/></td><td><xsl:val ue-of select="phone"/></td></tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
But that didn't work either. I'm at a loss. I figured this would be
easy but i'm guessing not. I've tried using the XML document with and
without the id="##" and that didn't do any good. Actually, let me
take
that back, it did pop up a column with all the id's but nothing else.
What do you suggest? I'm not keen on retyping the document but it
looks like that might be the only way. I was hoping that I could
input
the data in Excel and dump it out as XML and it'd work like magic.
The
sad thing is, I've seen examples doing it this way (minus the
ID="##")
and it worked fine. I don't know what I'm doing wrong.

May 19 '07 #1
5 1235

Option 1:
http://www.aspfree.com/c/a/XML/Apply...Using-ASP.NET/

Option 2:
http://sholliday.space s.live.com/Blog/cns!A68482B9628 A842A!148.entry

Option 3:
Rework the data. I would create a "strongly typed DataSet", and get the
data into that format.

If it were me, I'd pick between 2 or 3.
#2 if you don't have control over the source xml
#3 if you do have control over the creation of the source xml.
The gridview needs something to bind to. Usually that is row/column based
data.

A (single) table inside of of a DataSet is an example.
A DataView or DataTable is an example.
(among others).


"ky0t3" <ja*******@gmai l.comwrote in message
news:11******** **************@ p77g2000hsh.goo glegroups.com.. .
I'm trying to add XML to my my ASP.NET project and have it read by
the
gridview control or even the telerik radgrid control either way, it
doesn't work. I get an error about not finding and bindable
properties. Here's a sample of it:

<?xml version="1.0" encoding="UTF-8" standalone="yes "?>
<dealers xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
<dealer_item id="93">
<name>Auburn Harley Davidson</name>
<street>12075 Locksley Ln</street>
<city>Auburn</city>
<state>Californ ia</state>
<zip>95602</zip>
<phone>53088571 61</phone>
</dealer_item>
<dealer_item id="101">
<name>Backroa ds Custom Cycle</name>
<street>7939 A E 11th ST</street>
<city>Tracy</city>
<state>Californ ia</state>
<zip>95304</zip>
<phone>20983907 56</phone>
</dealer_item>
</dealers>
I even tried adding an XSL document to see if that would do the
trick:
<?xml version="1.0" ?>
<xsl:styleshe et version="1.0" xmlns:xsl="http ://www.w3.org/1999/XSL/
Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<table border="2" bgcolor="yellow ">
<tr>
<td>Title: <xsl:value-of select="dealer_ item"/>
</td>
</tr>
<tr><th>Deale r</th><th>Street</th><th>City</th><th>State</
th><th>Zip</
th><th>Phone #</th></tr>
<xsl:for-each select="dealers/dealer_item">
<tr><td><xsl:va lue-of select="dealer_ item"/></td><td><xsl:val ue-
of
select="street"/></td><td><xsl:val ue-of select="city"/></
td><td><xsl:val ue-of select="state"/></td><td><xsl:val ue-of
select="zip"/></td><td><xsl:val ue-of select="phone"/></td></tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
But that didn't work either. I'm at a loss. I figured this would be
easy but i'm guessing not. I've tried using the XML document with and
without the id="##" and that didn't do any good. Actually, let me
take
that back, it did pop up a column with all the id's but nothing else.
What do you suggest? I'm not keen on retyping the document but it
looks like that might be the only way. I was hoping that I could
input
the data in Excel and dump it out as XML and it'd work like magic.
The
sad thing is, I've seen examples doing it this way (minus the
ID="##")
and it worked fine. I don't know what I'm doing wrong.

May 19 '07 #2

"ky0t3" <ja*******@gmai l.comwrote in message
news:11******** **************@ p77g2000hsh.goo glegroups.com.. .
I'm trying to add XML to my my ASP.NET project and have it read by
the
gridview control or even the telerik radgrid control either way, it
doesn't work. I get an error about not finding and bindable
properties. Here's a sample of it:
You will need the XmlDataSource control that presents XML to data-bound
controls, such as a GridView.

Here's the complete code for your XML

<asp:GridView ID="GridView1" runat="server"
AutoGenerateCol umns="False"
DataSourceID="X mlDataSource1">

<Columns>

<asp:TemplateFi eld HeaderText="Nam e">
<ItemTemplate >
<%# XPath ("name") %>
</ItemTemplate>
</asp:TemplateFie ld>

<asp:TemplateFi eld HeaderText="Str eet">
<ItemTemplate >
<%# XPath ("street") %>
</ItemTemplate>
</asp:TemplateFie ld>

</Columns>

</asp:GridView>

<asp:XmlDataSou rce ID="XmlDataSour ce1"
runat="server" DataFile="XMLFi le1.xml"
XPath="dealers/dealer_item">
</asp:XmlDataSour ce>
May 19 '07 #3
Another option would be to just read the XML into a DataSet via its ReadXml
method. Assuming you get the correct table structure using the various
overloads, you can just Databind to the correct table in your DataSet.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"ky0t3" wrote:
I'm trying to add XML to my my ASP.NET project and have it read by
the
gridview control or even the telerik radgrid control either way, it
doesn't work. I get an error about not finding and bindable
properties. Here's a sample of it:

<?xml version="1.0" encoding="UTF-8" standalone="yes "?>
<dealers xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
<dealer_item id="93">
<name>Auburn Harley Davidson</name>
<street>12075 Locksley Ln</street>
<city>Auburn</city>
<state>Californ ia</state>
<zip>95602</zip>
<phone>53088571 61</phone>
</dealer_item>
<dealer_item id="101">
<name>Backroa ds Custom Cycle</name>
<street>7939 A E 11th ST</street>
<city>Tracy</city>
<state>Californ ia</state>
<zip>95304</zip>
<phone>20983907 56</phone>
</dealer_item>
</dealers>
I even tried adding an XSL document to see if that would do the
trick:
<?xml version="1.0" ?>
<xsl:styleshe et version="1.0" xmlns:xsl="http ://www.w3.org/1999/XSL/
Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<table border="2" bgcolor="yellow ">
<tr>
<td>Title: <xsl:value-of select="dealer_ item"/>
</td>
</tr>
<tr><th>Deale r</th><th>Street</th><th>City</th><th>State</
th><th>Zip</
th><th>Phone #</th></tr>
<xsl:for-each select="dealers/dealer_item">
<tr><td><xsl:va lue-of select="dealer_ item"/></td><td><xsl:val ue-
of
select="street"/></td><td><xsl:val ue-of select="city"/></
td><td><xsl:val ue-of select="state"/></td><td><xsl:val ue-of
select="zip"/></td><td><xsl:val ue-of select="phone"/></td></tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
But that didn't work either. I'm at a loss. I figured this would be
easy but i'm guessing not. I've tried using the XML document with and
without the id="##" and that didn't do any good. Actually, let me
take
that back, it did pop up a column with all the id's but nothing else.
What do you suggest? I'm not keen on retyping the document but it
looks like that might be the only way. I was hoping that I could
input
the data in Excel and dump it out as XML and it'd work like magic.
The
sad thing is, I've seen examples doing it this way (minus the
ID="##")
and it worked fine. I don't know what I'm doing wrong.

May 20 '07 #4

I should have mentioned, those were 3 options. But not the only ones.


"sloan" <sl***@ipass.ne twrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
>
Option 1:
http://www.aspfree.com/c/a/XML/Apply...Using-ASP.NET/

Option 2:
http://sholliday.space s.live.com/Blog/cns!A68482B9628 A842A!148.entry

Option 3:
Rework the data. I would create a "strongly typed DataSet", and get the
data into that format.

If it were me, I'd pick between 2 or 3.
#2 if you don't have control over the source xml
#3 if you do have control over the creation of the source xml.
The gridview needs something to bind to. Usually that is row/column based
data.

A (single) table inside of of a DataSet is an example.
A DataView or DataTable is an example.
(among others).


"ky0t3" <ja*******@gmai l.comwrote in message
news:11******** **************@ p77g2000hsh.goo glegroups.com.. .
I'm trying to add XML to my my ASP.NET project and have it read by
the
gridview control or even the telerik radgrid control either way, it
doesn't work. I get an error about not finding and bindable
properties. Here's a sample of it:

<?xml version="1.0" encoding="UTF-8" standalone="yes "?>
<dealers xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
<dealer_item id="93">
<name>Auburn Harley Davidson</name>
<street>12075 Locksley Ln</street>
<city>Auburn</city>
<state>Californ ia</state>
<zip>95602</zip>
<phone>53088571 61</phone>
</dealer_item>
<dealer_item id="101">
<name>Backroa ds Custom Cycle</name>
<street>7939 A E 11th ST</street>
<city>Tracy</city>
<state>Californ ia</state>
<zip>95304</zip>
<phone>20983907 56</phone>
</dealer_item>
</dealers>
I even tried adding an XSL document to see if that would do the
trick:
<?xml version="1.0" ?>
<xsl:styleshe et version="1.0" xmlns:xsl="http ://www.w3.org/1999/XSL/
Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<table border="2" bgcolor="yellow ">
<tr>
<td>Title: <xsl:value-of select="dealer_ item"/>
</td>
</tr>
<tr><th>Deale r</th><th>Street</th><th>City</th><th>State</
th><th>Zip</
th><th>Phone #</th></tr>
<xsl:for-each select="dealers/dealer_item">
<tr><td><xsl:va lue-of select="dealer_ item"/></td><td><xsl:val ue-
of
select="street"/></td><td><xsl:val ue-of select="city"/></
td><td><xsl:val ue-of select="state"/></td><td><xsl:val ue-of
select="zip"/></td><td><xsl:val ue-of select="phone"/></td></tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
But that didn't work either. I'm at a loss. I figured this would be
easy but i'm guessing not. I've tried using the XML document with and
without the id="##" and that didn't do any good. Actually, let me
take
that back, it did pop up a column with all the id's but nothing else.
What do you suggest? I'm not keen on retyping the document but it
looks like that might be the only way. I was hoping that I could
input
the data in Excel and dump it out as XML and it'd work like magic.
The
sad thing is, I've seen examples doing it this way (minus the
ID="##")
and it worked fine. I don't know what I'm doing wrong.


May 21 '07 #5
thanks for your help fellas. I ended up importing the data into an
access database and going that route. it works. not as cool as doing
XML, but it works. i'm going to have to look and spend some studying
on how asp.net works with XML as i'm just not as good as I should be
at it.

May 21 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5721
by: Enos Meroka | last post by:
Hallo, I am a student doing my project in the university.. I have been trying to compile the program using HP -UX aCC compiler, however I keep on getting the following errors. ================================================================= Error 19: "CORBAManagerMessages.h", line 4 # Unexpected 'std'. using std::string; ^^^
3
2167
by: Mike L | last post by:
Should the command call "using" be before or after my namespace? **AFTER** namespace DataGridBrowser { using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Collections;
3
2445
by: xzzy | last post by:
I was wondering why we have to have using System.Data using System.Configuration using etc.... why are they not all lumped into one 'using'? In other words, is there a best way to use project classes with 'using' meaning
14
5808
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the SQL DATABASE, probably by the click of a button. Is this possible? & what is the BEST APPROACH for doing this? & also if any links are there do tell those to me too coz I have no idea how to go about doing it.
8
2416
by: acb | last post by:
Hi, I wrote a DLL Component (using Visual Studio 2005) and managed to include it into a C# Console application. I am now trying to include this component into a Web project. I copy the DLL into the bin directory but am not able to progress. Can anyone please guide me to an online tutorial on the subject. Thanks,
0
2210
by: Metal2You | last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that accesses a Sybase database back end. We're using Sybase SQL Anywhere 9.0.2.3228. I have installed and registered the Sybase .NET 2.0 DataProvider (iAnywhere.Data.AsaClient.dll) into the GAC so it can be used in the ProviderName property of a SQLDataSource and loads properly at run time. The application I'm writing is a bit more complex than the example I'm about to...
10
1976
by: mg | last post by:
I'm migrating from VB6 and have a question about using 'Using' and the best way to use it. Here is a example of a small bit of code: dbConx("open") Using CN Dim CMD As New OleDbCommand(sSQL, CN) Dim DR As OleDbDataReader = CMD.ExecuteReader()
0
2579
by: Eugene Anthony | last post by:
The problem with my coding is that despite removing the records stored in the array list, the rptPages repeater control is still visible. The rptPages repeater control displayes the navigation link (1,2,3 so on). The code can be found in SubscriptionCart.aspx.cs. Default.aspx ------------
3
8305
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0 build with these methods, will appear to encrypt and decrypt, but the resulting decrypted file will be corrupted. I tried encrypting a .bmp file and then decrypting, the resulting decrypted file under .NET 2.0 is garbage, the .NET 1.1 build works...
6
5177
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick application working. However, when attempting to implement the solution, the AJAX calls weren't updating the screen like the examples were and seemed not to fire until after the long running process had completed. I found the only real...
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10353
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10099
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.