ADO Net Database ASP.Net Tutorial

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


    Untitled Page


    
    

        

    


File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 DataSetBinding : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DataSet dsInternal = new DataSet();
        dsInternal.Tables.Add("Users");
        dsInternal.Tables["Users"].Columns.Add("Name");
        dsInternal.Tables["Users"].Columns.Add("Country");
        DataRow rowNew = dsInternal.Tables["Users"].NewRow();
        rowNew["Name"] = "A";
        rowNew["Country"] = "USA";
        dsInternal.Tables["Users"].Rows.Add(rowNew);
        rowNew = dsInternal.Tables["Users"].NewRow();
        rowNew["Name"] = "B";
        rowNew["Country"] = "Canada";
        dsInternal.Tables["Users"].Rows.Add(rowNew);
        rowNew = dsInternal.Tables["Users"].NewRow();
        rowNew["Name"] = "C";
        rowNew["Country"] = "Japan";
        dsInternal.Tables["Users"].Rows.Add(rowNew);
        lstUser.DataSource = dsInternal.Tables["Users"];
        lstUser.DataTextField = "Name";
        lstUser.DataSource = dsInternal;
        lstUser.DataMember = "Users";
        lstUser.DataTextField = "Name";
        this.DataBind();
    }
}