 |
|
thaicreate.txt
C001,Win Weerachai,[email protected],TH,1000000,600000
C002,John Smith,[email protected],EN,2000000,800000
C003,Jame Born,[email protected],US,3000000,600000
C004,Chalee Angel,[email protected],US,4000000,100000
Code (VB.NET)
<%@ 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>

|
 |
 |
 |
 |
Date :
2012-03-22 15:26:07 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |