hi aabruzzese
thx for the reply :)
i found this on the bug list
and i try to use it but i am still a green noob in this :)
how do i edit the code behind the file ? :)
thx
Attila
This is the News_List.aspx Page:
<%@ Page Language="VB" MasterPageFile="~/Default.master" AutoEventWireup="false" CodeFile="News_List.aspx.vb" Inherits="News_List" Title="News Articles" %>
<%@ Register TagPrefix="Club" Namespace="ClubSite" %>
<%@ Register TagPrefix="Club" TagName="LoginBanner" Src="LoginBanner.ascx" %>
<%@ Register TagPrefix="Club" TagName="ImageThumbnail" Src="ImageThumbnail.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="body">
<Club:LoginBanner ID="LoginBanner1" runat="server" />
<!--
Left column
-->
<div id="columnleft">
<a name="content_start" id="content_start"></a>
<div class="leftblock">
<h2>
News Articles</h2>
<p>
Keep current on news and events for Check Raise Inc.
Recaps of our exciting events and tournaments are regularly posted here and any major events/site upgrades will be reported here as well.
</p>
</div>
</div>
<!--
Right column
-->
<div id="columnright">
<div class="rightblock">
<asp:panel ID=panel1 runat=server cssclass="actionbuttons">
<Club:RolloverLink ID="RemoveBtn" runat="server" Text="Add new Article" NavigateURL="News_Edit.aspx?Action=New" />
</asp:panel>
<div class="dashedline">
</div>
<!-- begin news item -->
<asp:Repeater ID="NewsRepeater" runat="server" >
<ItemTemplate>
<div class="listitem">
<div class="thumbnail">
<a href='<%# "News_View.aspx?Articleid=" &Cstr( Eval("ID"))%>'>
<Club:ImageThumbnail ID="ImageThumbnail1" runat="server" PhotoID='<%# Eval("photo") %>'
NoPhotoImg="images/news.jpg" />
</a>
</div>
<asp:panel ID=panel2 runat=server Visible='<%#IsAdmin %>'>
<Club:RolloverLink ID="EditBtn" runat="server" Text="Edit" NavigateURL='<%# "News_Edit.aspx?Action=Edit&ArticleID=" & Cstr( Eval("ID")) %>' />
<Club:RolloverLink ID="RemoveBtn" runat="server" Text="Remove" NavigateURL='<%# "News_Edit.aspx?Action=Remove&ArticleID=" & Cstr( Eval("ID")) %>' />
</asp:panel>
<h3>
<asp:Label ID="itemdateLabel" runat="server" Text='<%# Eval("itemdate","{0:d}") %>' />
<a href='<%# "news_view.aspx?articleid=" &Cstr( Eval("ID"))%>'>
<asp:Label ID="titleLabel" runat="server" Text='<%# Eval("title") %>' />
</a>
</h3>
<p>
<asp:Label ID="descriptionLabel" runat="server" Text='<%# truncate(CStr(Eval("description"))) %>' />
<a href='<%# "news_view.aspx?articleid=" &Cstr( Eval("ID"))%>'>read more »</a></p>
<div class="clearlist">
</div>
</div>
</ItemTemplate>
</asp:Repeater>
<div class="dashedline"></div>
<div class="newscrumbs">
Page: <asp:PlaceHolder id="PageButtons" runat="server"/>
</div>
</div>
</div>
<div class="clear2column"></div>
</div>
</asp:Content>
Here is the VB code for the Code Behind File.
Imports System
Imports System.Configuration
Imports System.Data
Imports System.Data.Common
Imports System.Data.SqlClient
Imports System.Data.OleDb
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Partial Class News_List
Inherits System.Web.UI.Page
Dim DBConnection As SqlConnection
Dim DBCommand As SqlCommand
Dim DBReader As SqlDataReader
Dim SQLString As String
Dim PageSize As Integer = 4
Public IsAdmin As Boolean
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
IsAdmin = User.IsInRole("Administrators")
panel1.Visible = IsAdmin
If Not Page.IsPostBack Then
Fill()
End If
'-- Load array NewsIdList() with item numbers
Dim NewsIdList = New ArrayList()
DBConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("ClubSiteDB").ConnectionString)
SQLString = "SELECT id, itemdate FROM Announcements " & _
"ORDER BY id DESC, itemdate DESC"
DBConnection.Open()
DBCommand = New SqlCommand(SQLString, DBConnection)
DBReader = DBCommand.ExecuteReader()
While DBReader.Read()
NewsIdList.Add(DBReader("id"))
End While
DBReader.Close()
DBConnection.Close()
NewsIdList.TrimToSize()
'-- Create Paging Buttons
Dim StartIndex As Integer
Dim EndIndex As Integer
Dim StartKey As String
Dim EndKey As String
Dim StartDate As DateTime
Dim i As Integer
StartIndex = 0
For i = 1 To Math.Ceiling(NewsIdList.Count / PageSize)
'-- Determine starting and ending array indexes
EndIndex = StartIndex + PageSize - 1
If EndIndex > NewsIdList.Count - 1 Then
EndIndex = NewsIdList.Count - 1
End If
'-- Assign starting and ending item numbers
StartKey = NewsIdList(StartIndex)
EndKey = NewsIdList(EndIndex)
'-- Create a button and assign to placeholder
Dim PageButton As Button
PageButton = New Button()
PageButton.Text = i
PageButton.ID = "P" & i
PageButton.CommandName = StartKey & "|" & EndKey
PageButton.Style("width") = "20px"
PageButton.Style("background-color") = "#F0F0F0"
AddHandler PageButton.Command, AddressOf DisplayRepeater
PageButtons.Controls.Add(PageButton)
StartIndex += PageSize
Next
If Not Page.IsPostBack Then
Dim FirstButton As Button
FirstButton = CType(PageButtons.FindControl("P1"), Button)
FirstButton.Style("background-color") = "#990000"
FirstButton.Style("color") = "#FFFFFF"
End If
End Sub
Sub Fill()
Dim DBConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("ClubSiteDB").ConnectionString)
SQLString = "SELECT Top " & PageSize & _
" id, itemdate, title, description, photo FROM Announcements " & _
"ORDER BY itemdate DESC, id DESC"
DBConnection.Open()
DBCommand = New SqlCommand(SQLString, DBConnection)
DBReader = DBCommand.ExecuteReader()
NewsRepeater.DataSource = DBReader
NewsRepeater.DataBind()
DBReader.Close()
DBConnection.Close()
End Sub
Sub DisplayRepeater(ByVal Src As Object, ByVal Args As CommandEventArgs)
Dim Keys() As String
Keys = Split(Args.CommandName, "|")
'-- Bind the Repeater
DBConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("ClubSiteDB").ConnectionString)
DBConnection.Open()
SQLString = "SELECT id, itemdate, title, description, photo FROM Announcements WHERE " & _
"id >= '" & Keys(1) & "' AND " & _
"id <= '" & Keys(0) & "' " & _
"ORDER BY id DESC, itemdate DESC"
DBCommand = New SqlCommand(SQLString, DBConnection)
DBReader = DBCommand.ExecuteReader()
NewsRepeater.DataSource = DBReader
NewsRepeater.DataBind()
DBReader.Close()
DBConnection.Close()
'-- Highlight clicked button
Dim Item As Button
Dim ThisButton As Button
For Each Item In PageButtons.Controls
ThisButton = CType(Item, Button)
ThisButton.Style("background-color") = "#F0F0F0"
ThisButton.Style("color") = "#000000"
Next
ThisButton = CType(PageButtons.FindControl(Src.id), Button)
ThisButton.Style("background-color") = "#990000"
ThisButton.Style("color") = "#FFFFFF"
End Sub
End Class