Using XMLDataSource control in ASP.net:
In this article I'm trying to explain how to work with XMLDataSource control for displaying database data to our DataControls. During this process we can able to learn how to configure LinqDataSource control and how to connect with DataControl. This is very simple to communicate with our Database.
Follow below steps to configure XMLDataSource control in our Application.
Add an XML file in the solution explorer by right click on the project then choose XML File option in the list and give a name for that as employee.xml and then click on Add button a new XML file has been created under the project folder.
Open that xml file and design that like below manner.
<?xml version="1.0" encoding="utf-8" ?>
<emp Name="Naveen" Id="1" Sal="15000"></emp>
<emp Name="Karthi" Id="2" Sal="20000"></emp>
<emp Name="Pawan" Id="3" Sal="25000"></emp>
Drag and drop XMLDataSource control on the design view of the webpage then click on the smart tag to configure DataSource.
Then a new popup window will appear for configure XMLDataSource purpose. Choose DataFile available in the project and then click on OK button.
After adding the XML file then click on Ok button to configure XMLDataSource.
Now, XML Configuration process has been completed successfully, now simply drag & drop gridview control to the design view of the page and then choose XMLDataSource from Choose Data Source dropdown then click on Ok button then see the Gridview control changes.
See the Source code part of Gridview control, how it was configure in source.
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" />
<asp:BoundField DataField="Sal" HeaderText="Sal" SortExpression="Sal" />
Now, the times to check the output result just press F5 on keyboard and see the result.
I hope this article will help you those who are looking for the same and those who are new to implement XMLDataSource control in your applications.
This is Naveen, I completed my MCA and I have around 3 years of experience in ASP.net while implement Web Applications. For past 3 years I learn no.of Technologies while implement my applications apart from that I try to learn new technologies and I try to implement that while implement my project.