Imports System
Imports System.Data
Partial Class articles
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Session("three") = "three"
        If Not IsPostBack Then

            FillCategoryGrid()

        End If

    End Sub

    Public Sub FillCategoryGrid()

        Dim dt As DataTable
        dt = ReturnDataTable("SELECT DISTINCT Category_Distinct.Category_Name, Category_Distinct.CategoryName, Category_Distinct.Category_Kid FROM         Category_Distinct LEFT OUTER JOIN                       Article_Master ON Category_Distinct.Category_Kid = Article_Master.Article_CategoryId WHERE     (Article_Master.Article_IsDeleted = N'0') AND (Article_Master.Article_Status = N'Publish')ORDER BY Category_Distinct.Category_Name")
        gvCategory.Columns(1).Visible = True
        gvCategory.DataSource = dt
        gvCategory.DataBind()
        gvCategory.Columns(1).Visible = False

    End Sub

    
    Protected Sub gvCategory_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvCategory.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim dt As DataTable
            dt = ReturnDataTable("Select top(3) * from ArticleTitle where Category_Kid ='" & RemoveLiterals(e.Row.Cells(1).Text.ToString) & "' order by Article_PublishDate desc")
            Dim gv As GridView
            gv = CType(e.Row.Cells(0).FindControl("gvArticle"), GridView)
            gv.DataSource = dt
            gv.DataBind()
            If (dt.Rows.Count <> 3) Then
                CType(e.Row.Cells(0).FindControl("hlMore"), HyperLink).Visible = False
            End If
        End If
    End Sub
End Class
