Imports System.XMLImports System.DataPartial Class LoadXMLtoGridview Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then BindGridView1() End If End Sub Protected Sub BindGridView1() Dim dataUrl As String = "~/App_Data/USA.xml" Dim ds As DataSet = New DataSet ds.ReadXml(Server.MapPath(dataUrl)) Dim dv As DataView = New DataView(ds.Tables(0)) GridView1.DataSource = dv GridView1.DataBind() End SubEnd Class
We first need to call the Imports.XML and System.Data to manage our XML and data routines.
Then Dimension out a DS for our Data Set and DV for our Data View.
Last we bind the GridView1 to our Data View and call the protected sub routine on page load.
Download Files:LoadXMLtoGridview.aspxLoadXMLtoGridview.vbUSA.xml