Private Sub GenNewProductTable()
Dim count As Integer
Dim sql = "select ProductID,ProductName,ImgProduct,Description,NewProduct," & _
"Price from Product where NewProduct = 1"
Dim dt = mUtilities.getDatatable(sql)
If dt.Rows.Count > 0 Then
Dim tr As HtmlTableRow
Dim tc1 As HtmlTableCell
Dim tc2 As HtmlTableCell
Dim tbname As String
count = 0
'Dim int As Integer
Dim bestseller As Control_ProductList
Dim detailcount As Integer = dt.Rows.Count
Dim flagAdd As Boolean
'If ptb.Rows.Count > 0 Then
For Each dr As DataRow In dt.Rows
flagAdd = False
bestseller = Me.LoadControl("Control/ProductList.ascx")
bestseller.data_row = dr
If Session("name") <> "" Then
bestseller.flag = True
Else
bestseller.flag = False
End If
If count Mod 3 = 0 Then
tr = New HtmlTableRow
tr.Align = HorizontalAlign.Left
tc1 = New HtmlTableCell
tc1.Align = HorizontalAlign.Left
tc1.Controls.Add(bestseller)
tr.Cells.Add(tc1)
'Else
If count = detailcount Then
'tbSpecial.Rows.Add(tr)
End If
ElseIf count Mod 3 = 1 Then
tc1 = New HtmlTableCell
tc1.Align = HorizontalAlign.Left
tc1.Controls.Add(bestseller)
tr.Cells.Add(tc1)
If count = detailcount Then
'tbSpecial.Rows.Add(tr)
End If
Else
'tr = New TableRow
tc2 = New HtmlTableCell
tc2.Align = HorizontalAlign.Left
tc2.Controls.Add(bestseller)
tr.Cells.Add(tc2)
tbNew.Rows.Add(tr)
flagAdd = True
End If
count = count + 1
Next
If Not flagAdd Then
tbNew.Rows.Add(tr)
End If
End If
End Sub
Tag : .NET, Ms SQL Server 2005, Web (ASP.NET), VB.NET