Bind the XML file as a data source to the control

Source: Internet
Author: User
<% @ Import namespace="System. Data"  %>

< Html >

< Head >

< Title > Bind the XML file as a data source to the control </ Title >

< Script Language = "C #" Runat = "Server" >

Void Page_load (Object sender, system. eventargs E)

{

// Create a DataSet object

Dataset myds =   New Dataset ();

// Read XML files into Dataset

Myds. readxml (server. mappath ( " People. xml " ));

// Display the table name in Dataset

Label1.text =   " The table name is: "   + Myds. Tables [ 0 ]. Tablename;

// Bind to DataGrid

Datagrid1.datasource = Myds. Tables [ 0 ];

Datagrid1.databind ();

}



</ Script >

</ Head >

< Body >

< Form ID = "Form1" Method = "Post" Runat = "Server" >

< H3 > Bind the XML file as a data source to the control </ H3 >

< ASP: Label ID = "Label1" Runat = "Server" > Label </ ASP: Label >

< BR >

< ASP: DataGrid ID = "Datagrid1" Runat = "Server" > </ ASP: DataGrid >

</ Form >

</ Body >

</ Html >

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.