Hi...
See this one, using datalist and mysql for displaying images.
In aspx:
<asp:DataList ID="DataList1" runat="server" Height="82px"
ItemStyle-HorizontalAlign="Center" RepeatColumns="3" Width="180px" EnableViewState="true">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:Image ID="img1" ImageUrl='<%# Bind("Name", "~/Images/{0}") %>' Width="250" Height="180" runat="server" />
<asp:HyperLink ID="HyperLink1" Text='<%# Bind("Name") %>' NavigateUrl='<%# Bind("Name", "~/Images/{0}") %>' runat="server"/>
</ItemTemplate>
</asp:DataList>
<asp:button id="btnpv" text="previous" runat="server" style="font-weight: 700" visible="true" width="66px" onclick="btnpv_Click" xmlns:asp="#unknown" />
<asp:button id="btnx" text="Next" runat="server" style="font-weight: 700" visible="true" width="52px" onclick="btnx_Click" xmlns:asp="#unknown" />
In aspx.cs:
//in page_load only
DirectoryInfo dir = new DirectoryInfo(MapPath("Images"));
FileInfo[] files = dir.GetFiles();
ArrayList listitems = new ArrayList();
foreach (FileInfo info in files)
{
if (info.Extension == ".jpg" || info.Extension == ".jpeg" || info.Extension == ".gif" || info.Extension == ".png")
{
listitems.Add(info);
}
}
adsource = new PagedDataSource();
adsource.DataSource = listitems;
adsource.PageSize = 3;
adsource.AllowPaging = true;
adsource.CurrentPageIndex = pos;
btnx.Visible = true;
btnpv.Visible = true;
btnpv.Enabled = !adsource.IsFirstPage;
DataList1.DataSource = adsource;
DataList1.DataBind();
protected void btnx_Click(object sender, EventArgs e)
{
pos = (int)this.ViewState["vs"];
pos += 1;
this.ViewState["vs"] = pos;
Getimg();
}
protected void btnpv_Click(object sender, EventArgs e)
{
pos = (int)this.ViewState["vs"];
pos -= 1;
this.ViewState["vs"] = pos;
Getimg();
}
Thank u.