Here is a practical example - let's say you want to populate the grid with this XML data, located in "data.xml" file:
<?xml version="1.0" encoding="utf-8" ?> <Employee> <em> <id>1</id> <name>Florian</name> <phone>123</phone> </em> <em> <id>2</id> <name>Andreas</name> <phone>234</phone> </em> <em> <id>3</id> <name>Martin</name> <phone>345</phone> </em> </Employee>
You just need to drag a jqGrid instance to the ASPX page. Remember to also define the columns.
<trirand:JQGrid ID="XmlGrid" runat="server"> <Columns> <trirand:JQGridColumn DataField="id" /> <trirand:JQGridColumn DataField="name" /> <trirand:JQGridColumn DataField="phone" /> </Columns> </trirand:JQGrid>
And then read the XML into an ADO.NET DataSet and bind the grid:
protected void Page_Load(object sender, EventArgs e) { DataSet ds = new DataSet(); ds.ReadXml(Server.MapPath("~/data.xml")); XmlGrid.DataSource = ds; XmlGrid.DataBind(); }