Come da oggetto....
DataGrid & Paginazione più che altro la visualizzazione....
Nel senso... la paginazione basta abilitarla e funge
Ora quello che mi interessava è poter visualizzare
l'elenco delle immagini della galleria in paginate
da 16 immagini disposte nel seguente modo :
codice:
[00] [01] [02] [03]
[04] [05] [06] [07]
[08] [09] [10] [11]
[12] [13] [14] [15]
Come devo modificare il codice seguente per fare ciò?
La pagina si appoggia ad un DB Access strutturato così:
codice:
id : contatore
file : testo [255] // contiene il nome del file.
Codice PHP:
<%@ Page Language="C#" LCID="1040" AutoEventWireup="true" %>
<%@ import Namespace="System.Web" %>
<%@ import Namespace="System.Web.UI" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script Language = "C#" runat = "server">
void Page_Load(Object sender, EventArgs e)
{
if (!Page.IsPostBack)
Elenco();
}
public string ConnectionString()
{
return ("PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("~/gallery/images.mdb") + ";");
}
void Elenco()
{
string strsql = "SELECT file FROM Images ORDER BY file ASC;";
OleDbConnection odbconn= new OleDbConnection(ConnectionString());
odbconn.Open();
OleDbDataAdapter odbda = new OleDbDataAdapter(strsql, odbconn);
DataSet ds = new DataSet();
odbda.Fill(ds, "Images");
odbconn.Close();
imgElenco.DataSource = ds.Tables["Images"];
imgElenco.DataMember = "Images";
imgElenco.DataBind();
} // void Elenco()
void NewGridPage(Object sender, DataGridPageChangedEventArgs e)
{
imgElenco.CurrentPageIndex = e.NewPageIndex;
Elenco();
} // void NewGridPage(Object sender, DataGridPageChangedEventArgs e)
string CreateImageTag(object dato)
{
string thumbsPath = (Path.GetDirectoryName(ConfigurationSettings.AppSettings["ThumbnailsFolder"]) + "/").Replace("\\", "/");
string highPath = (Path.GetDirectoryName(ConfigurationSettings.AppSettings["HighResImageFolder"]) + "/").Replace("\\", "/");
string fileName = dato.ToString();
string temp = "";
if (File.Exists(Server.MapPath(highPath + fileName)))
{
temp += "<a href=\"" + highPath + fileName + "\" title=\"" + Path.GetFileNameWithoutExtension(fileName) + "\" target=\"_blank\">";
temp += "<img src=\"" + thumbsPath + fileName + "\" alt=\"" + fileName + "\" border=\"0\">";
temp += "</a>";
}
else
temp += ""; // lascia posto vuoto.
return temp;
}
</script>
<html>
<body bgcolor="darkgrey">
<h2>[i]Galleria Immagini[/i] :</h2>
<form runat="server">
<asp:DataGrid id = "imgElenco"
BorderStyle = "None"
GridLines = "None"
BorderWidth = "0px"
BorderColor = "Black"
CellSpacing = "3"
CellPadding = "3"
ShowHeader = "False"
ShowFooter = "True"
DataKeyField = "File"
AutoGenerateColumns = "False"
AllowPaging = "True"
AllowCustomPaging = "False"
PageSize = "16"
OnPageIndexChanged = "NewGridPage"
runat = "server">
<PagerStyle Mode="NumericPages" HorizontalAlign="center" Position="top" BackColor="#2288DD" Width="700px"></PagerStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<%# CreateImageTag(DataBinder.Eval(Container.DataItem, "File")) %>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</form>
</body>
</html>
E' abbastanza urgente!
Rigranzio in anticipo chiunque possa darmi delle dritte per
disincagliarmi da sto punto di non ritorno per me
ma per voi sicuramente di facile risoluzione.