.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

xml in C#

Posted By: vikas     Posted Date: January 03, 2010    Points:2   Category :ASP.Net
i hav a xml file in asp.net with c# application.it contain data
<Root>
<Inbox id="1" assigned_user_id="" bcc_address="" bcc_address_names="" cc_address="" cc_address_names="" to_address="" />
</Root>
i want to select data from xml file where id=1;
then outcome output bind with Detalview..

Responses
Author: Lalij Mer             
Posted Date: January 05, 2010     Points: 5   

Show this example you may get idea.

do first create a new XML-File and populate it with some data,show here example:

<?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>


bind xml file to gridview

Drag a GridView control on your web form. Next you need some code to bind the data from the XML-file to your GridView.

Imports System.Data
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim oDs As New DataSet
oDs.ReadXml(Request.PhysicalApplicationPath + "XMLFile.xml")
GridView1.DataSource = oDs
GridView1.DataBind()
End Sub
End Class


At the Page_Load event we create a new DataSet and use the method ReadXml to get the data from the XML-file. Then we bind the DataSet to the GridView

Please Check my answer if you help....
Thank You...

Lalit.


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend