<%@ Import Namespace="System.IO"%>
<%@ Import Namespace="System.Data"%>
<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
BindData()
End Sub
Sub BindData()
Dim dt As New DataTable
Dim dr As DataRow
'*** Column ***'
dt.Columns.Add("CustomerID")
dt.Columns.Add("Name")
dt.Columns.Add("Email")
dt.Columns.Add("CountryCode")
dt.Columns.Add("Budget")
dt.Columns.Add("Used")
Dim StrWer As StreamReader
Dim readLine As String
StrWer = File.OpenText(Server.MapPath("thaicreate.txt"))
Do Until StrWer.EndOfStream
readLine = StrWer.ReadLine()
'*** Rows ***'
dr = dt.NewRow
dr("CustomerID") = Split(readLine,",")(0)
dr("Name") = Split(readLine,",")(1)
dr("Email") = Split(readLine,",")(2)
dr("CountryCode") = Split(readLine,",")(3)
dr("Budget") = Split(readLine,",")(4)
dr("Used") = Split(readLine,",")(5)
dt.Rows.Add(dr)
Loop
StrWer.Close()
myGridView.DataSource = dt
myGridView.DataBind()
End Sub
</script>
<html>
<head>
<title>ThaiCreate.Com ASP.NET - GridView</title>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView id="myGridView" runat="server"></asp:GridView>
</form>
</body>
</html>