TestPage.aspx


<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="TestPage.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h1>
            This is heading 1</h1>
        <h2>
            Heading 2</h2>
        <h3>
            Heading 3</h3>
        <h4>
            Heading 4</h4>
        <p>
            And this is a paragraph</p>
        <p>
            html table 
            <asp:GridView ID="testGrid" runat="server">
            </asp:GridView>
             </p>
    </div>
    </form>
</body>
</html>

TestPage.aspx.cs


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //this.testTable
        this.testGrid.DataSource = getSampleDataset();
        this.testGrid.DataBind();
    }
    private DataSet getSampleDataset()
    {
        DataSet ds = new DataSet();
        string xmlData = "<XmlDS>";
        xmlData+= "<table1><col1>Value1</col1><col2>value</col2></table1>";
        xmlData += "<table1><col1>Value2</col1><col2>value</col2></table1>";
        xmlData += "<table1><col1>Value2</col1><col2>value</col2></table1>";
        xmlData += "<table1><col1>Value2</col1><col2>value</col2></table1>";
        xmlData += "<table1><col1>Value2</col1><col2>value</col2></table1>";
        xmlData+= "</XmlDS>";
        System.IO.StringReader xmlsr = new System.IO.StringReader(xmlData);
        ds.ReadXml(xmlsr, XmlReadMode.InferSchema);
        return ds;
    }
}//eof-class

satya - Wednesday, April 18, 2007 3:19:04 PM

The runat=server command

Indicates that the xml tag is interpreted in some manner on the server side. If it is excluded then the xml is passed to the browser for interpretation

satya - Wednesday, April 18, 2007 3:20:25 PM

script with a runat=server

This usually includes c# code that will become part of this object at run time. Usually this kind of code belongs in code behind

satya - Wednesday, April 18, 2007 3:21:14 PM

The page directive

Indicates language, what source file and what code behind class

satya - Wednesday, April 18, 2007 3:22:10 PM

Check the syntax for page directive and other elements here

Check the syntax for page directive and other elements here