MaysamSh

Untitled

Aug 5th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.73 KB | None | 0 0
  1.     Public Function NewsArchive(ByVal iConnectionName As String, ByVal iTable As String, ByVal iRepeater As Repeater,
  2.                                ByVal iPageSizeCount As Integer,
  3.                                        ByVal iOrderBy As String, ByVal iOrderAscending As Boolean,
  4.                                        ByVal iCurrenPage As Integer) As String
  5.         SetActionResult = "waiting_NewsArchive"
  6.         Dim tempTrailer As String = ""
  7.         Dim TempSQLCommand As String = ""
  8.         Dim tempOrderType As String = IIf(iOrderAscending, "ASC", "DESC")
  9.         TempSQLCommand = "SELECT * FROM " & iTable & " WHERE VISIBLE=1 ORDER BY " & Trim(iOrderBy) & " " & tempOrderType
  10.         Dim Conn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("DataBaseConnection").ConnectionString)
  11.  
  12.         Try
  13.  
  14.             Conn.Open()
  15.             Dim DA As SqlDataAdapter = New SqlDataAdapter(TempSQLCommand, Conn)
  16.             Dim DT As DataTable = New DataTable()
  17.             DA.Fill(DT)
  18.  
  19.             Dim objPds As PagedDataSource = New PagedDataSource()
  20.             objPds.DataSource = DT.DefaultView
  21.  
  22.             objPds.AllowPaging = True
  23.  
  24.             objPds.PageSize = iPageSizeCount
  25.  
  26.             Dim curpage As Integer = iCurrenPage
  27.  
  28.             objPds.CurrentPageIndex = iCurrenPage - 1
  29.  
  30.             SetNewsArchivePageCount = objPds.PageCount
  31.  
  32.             iRepeater.DataSource = objPds
  33.             iRepeater.DataBind()
  34.             Conn.Close()
  35.             SetActionResult = "done_NewsArchive"
  36.         Catch exp As Exception
  37.             SetErrorMessage = exp.Message
  38.             SetActionResult = "error_NewsArchive"
  39.             Conn.Close()
  40.  
  41.         End Try
  42.  
  43.         Return tempTrailer
  44.     End Function
Advertisement
Add Comment
Please, Sign In to add comment