Imports System.Data

Partial Class viewNews
    Inherits System.Web.UI.UserControl

    Protected Sub grdFill()
        Dim db As New FirstClass()
        Dim dt As New DataTable()

        dt = db.dbOut("SELECT TOP 100 PERCENT dbo.tblNews.NewsID AS nwsID, dbo.tblNews.NewsTitle AS nwsTitle, dbo.NewsGroups.NewgGroupDescription AS nwsGroup, " & vbCr & vbLf & " dbo.Users.Name + N' ' + dbo.Users.Sname AS Expr1, dbo.tblNews.DateOfAdding AS nwsDtadd, dbo.tblNews.NewsPic, dbo.tblNews.newsBody, SUBSTRING(dbo.tblNews.newsBody, 1, 700) AS NewsPart, dbo.tblNews.ShowPermiss" & vbCr & vbLf & " FROM dbo.tblNews INNER JOIN dbo.Users ON dbo.tblNews.UserName = dbo.Users.UserName INNER JOIN dbo.NewsGroups ON dbo.tblNews.NewsGroupID = dbo.NewsGroups.NewsGroupID WHERE (dbo.tblNews.ArchivedBit = 0) AND (dbo.tblNews.ShowPermiss = 1)" & vbCr & vbLf & " ORDER BY dbo.tblNews.NewsID DESC")

        GridView1.DataSource = dt
        GridView1.DataBind()
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        grdFill()
    End Sub

    Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging
        GridView1.PageIndex = e.NewPageIndex
        grdFill()
    End Sub
End Class
