ใช้ Control DataList ก็ได้น่ะครับ โดยใช่การแบ่งเป็น Column ครับ
Code (VB.NET)
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.SqlClient"%>
<%@ Page Language="VB" %>
<script runat="server">
Dim objConn As SqlConnection
Dim objCmd As SqlCommand
Sub Page_Load(sender As Object, e As EventArgs)
Dim strConnString As String
strConnString = "Server=localhost;UID=sa;PASSWORD=;database=mydatabase;Max Pool Size=400;Connect Timeout=600;"
objConn = New SqlConnection(strConnString)
objConn.Open()
BindData()
End Sub
Sub BindData()
Dim strSQL As String
strSQL = "SELECT * FROM category"
Dim dtReader As SqlDataReader
objCmd = New SqlCommand(strSQL, objConn)
dtReader = objCmd.ExecuteReader()
'*** BindData to DataList ***'
myDataList.DataSource = dtReader
myDataList.DataBind()
dtReader.Close()
dtReader = Nothing
End Sub
Sub Page_UnLoad()
objConn.Close()
objConn = Nothing
End Sub
</script>
<html>
<head>
<title>ThaiCreate.Com ASP.NET - DataList</title>
</head>
<body>
<form id="form1" runat="server">
<asp:DataList id="myDataList" RepeatColumns="2" runat="server">
<HeaderTemplate>
<b>My Category</b>
</HeaderTemplate>
<ItemTemplate>
<div style="width:100px" align="center">
<img src="<%#Container.DataItem("Picture")%>">
<br />
<%#Container.DataItem("CategoryName")%>
</div>
</ItemTemplate>
<SeparatorTemplate>
<hr />
</SeparatorTemplate>
</asp:DataList>
</form>
</body>
</html>