Live Chat Icon For mobile
Live Chat Icon

How to filter xml data and display data in the DataGrid

Platform: ASP.NET| Category: ADO.NET

<?xml version='1.0' encoding='utf-8' ?> 
<products> 
	  <product prodId='product1-00' param1='11' /> 
	  <product prodId='product1-00' param1='12' /> 
	  <product prodId='product1-01' param1='13' /> 
	  <product prodId='product1-02' param1='14' /> 
	  <product prodId='product2-00' param1='21' param2='22' /> 
	  <product prodId='product2-00' param1='31' param2='32' /> 
	  <product prodId='product2-01' param1='41' param2='42' /> 
</products> 

VB.NET


Dim ds As New DataSet
ds.ReadXml(Server.MapPath('data1.xml'))
Dim dv As New DataView
dv = ds.Tables(0).DefaultView
dv.RowFilter = 'prodId=’product2-00’'
Me.DataGrid1.DataSource = dv
Me.DataBind()

C#


DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath('data1.xml'));
DataView dv = new DataView();
dv = ds.Tables[0].DefaultView;
dv.RowFilter = 'prodId=’product2-00’';
this.DataGrid1.DataSource = dv;
this.DataBind();

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.