Hi Mark,
No problem doing what you want to do. Here's one way, there are probably
many others.
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles MyBase.Load
' Ken Cox - Microsoft MVP [ASP.NET] Feb 13/04
' Create a stringbuilder to hold the XML
Dim sb As New System.Text.Str ingBuilder
' Create a dataset to hold the data
Dim ds As New DataSet
' create a TextReader to get the XML
Dim xmlrder As System.Xml.XmlT extReader
' Build some sample XML data (must be well-formed)
sb.Append("<?xm l version=""1.0"" standalone=""ye s""?>")
sb.Append("<Can adaPostalCodes> ")
sb.Append("<Pos tal_Code>")
sb.Append("<FSA >A0A</FSA>")
sb.Append("<LDA >1A0</LDA>")
sb.Append("<Pro vince>NEWFOUNDL AND AND LABRADOR</Province>")
sb.Append("<Typ e>Rural</Type>")
sb.Append("<Del iveryInstallati on>AQUAFORTE
PO</DeliveryInstall ation>")
sb.Append("<Key >1</Key>")
sb.Append("</Postal_Code>")
sb.Append("<Pos tal_Code>")
sb.Append("<FSA >A0A</FSA>")
sb.Append("<LDA >1B0</LDA>")
sb.Append("<Pro vince>NEWFOUNDL AND AND LABRADOR</Province>")
sb.Append("<Typ e>Rural</Type>")
sb.Append("<Del iveryInstallati on>AVONDALE
PO</DeliveryInstall ation>")
sb.Append("<Key >2</Key>")
sb.Append("</Postal_Code>")
sb.Append("</CanadaPostalCod es>")
' Point the xmltextreader to the string full of xml and
' tell it to expect an XML document
xmlrder = New System.Xml.XmlT extReader _
(sb.ToString, System.Xml.XmlN odeType.Documen t, Nothing)
' Read all of the XML as one chunk
xmlrder.ReadOut erXml()
' Read the outer XML into the Dataset
ds.ReadXml(xmlr der)
' Tell the datagrid to use this dataset
DataGrid1.DataS ource = ds
' Bind the data
DataGrid1.DataB ind()
End Sub
Does this help?
Ken
Microsoft MVP [ASP.NET]
"Mark" <an*******@disc ussions.microso ft.com> wrote in message
news:28******** *************** ***********@mic rosoft.com...
Can I bind datagrid to an xml string (not to file)? For example, the
result of transformation?