473,320 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Image gallery with DataGrid

Hi everyone!

I want to do da Image gallery using just the datagrid, this one will dilpays
only images, no text, that means that it will have about 4 Collumns that will
displays just images from the same database table, from the same collumn of
the table. However I could not reproduce this, since each Row (with 4
collumns) displays 4 times the same image. How can i fix it?

here is a part of the code:

<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Image Runat='server' ID='thumb' Width='140' Height='110' ImageUrl='<%#
DataBinder.Eval(Container.DataItem, "path") %'></asp:Image>
<asp:Image Runat='server' ID="Image1" Width='140' Height='110' ImageUrl='<%#
DataBinder.Eval(Container.DataItem, "path") %'></asp:Image>
<asp:Image Runat='server' ID="Image2" Width='140' Height='110' ImageUrl='<%#
DataBinder.Eval(Container.DataItem, "path") %'></asp:Image>
<asp:Image Runat='server' ID="Image3" Width='140' Height='110' ImageUrl='<%#
DataBinder.Eval(Container.DataItem, "path") %'></asp:Image>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>

Just not to post other topic: The datasource of this datagrid is "created"
when the user clicks on the button of an Album. Since an Album can contains
many photos, I'll use paging in this datagrid, however when I click on the
pagers, the datagrid disspears.

Code:

Dim cm As New Data.OleDb.OleDbDataAdapter("SELECT id, [path],[desc] FROM
fotos WHERE [album]=?", cn)
'' Dim ds As New Data.DataSet
cm.SelectCommand.Parameters.Add("album", ddlAlbum.SelectedValue)
ds.Clear()
cn.Open()
cm.Fill(ds)
cn.Close()
' Stop
dgImg.DataSource = ds
dgImg.DataBind()

The PageIndexChanged event is also done:
If e.NewPageIndex >= 0 Then
dgImg.CurrentPageIndex = e.NewPageIndex
dgImg.DataBind()
End If
Any help would be very apprecciated.

Thanks in advance
Nov 19 '05 #1
1 2196
Hi there,

In order to page datagrid, you have to rebind the datagrid's data source.

dgImg.CurrentPageIndex = e.NewPageIndex
dgImg.DataSource = ds
dgImg.DataBind()

The ds can be got either by requering DB, or in the first query to save ds
in Session, then retrieve it from Session.

If you have more questions, please let us know.

HTH

Elton Wang
el********@hotmail.com


"ltt19" wrote:
Hi everyone!

I want to do da Image gallery using just the datagrid, this one will dilpays
only images, no text, that means that it will have about 4 Collumns that will
displays just images from the same database table, from the same collumn of
the table. However I could not reproduce this, since each Row (with 4
collumns) displays 4 times the same image. How can i fix it?

here is a part of the code:

<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Image Runat='server' ID='thumb' Width='140' Height='110' ImageUrl='<%#
DataBinder.Eval(Container.DataItem, "path") %'></asp:Image>
<asp:Image Runat='server' ID="Image1" Width='140' Height='110' ImageUrl='<%#
DataBinder.Eval(Container.DataItem, "path") %'></asp:Image>
<asp:Image Runat='server' ID="Image2" Width='140' Height='110' ImageUrl='<%#
DataBinder.Eval(Container.DataItem, "path") %'></asp:Image>
<asp:Image Runat='server' ID="Image3" Width='140' Height='110' ImageUrl='<%#
DataBinder.Eval(Container.DataItem, "path") %'></asp:Image>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>

Just not to post other topic: The datasource of this datagrid is "created"
when the user clicks on the button of an Album. Since an Album can contains
many photos, I'll use paging in this datagrid, however when I click on the
pagers, the datagrid disspears.

Code:

Dim cm As New Data.OleDb.OleDbDataAdapter("SELECT id, [path],[desc] FROM
fotos WHERE [album]=?", cn)
'' Dim ds As New Data.DataSet
cm.SelectCommand.Parameters.Add("album", ddlAlbum.SelectedValue)
ds.Clear()
cn.Open()
cm.Fill(ds)
cn.Close()
' Stop
dgImg.DataSource = ds
dgImg.DataBind()

The PageIndexChanged event is also done:
If e.NewPageIndex >= 0 Then
dgImg.CurrentPageIndex = e.NewPageIndex
dgImg.DataBind()
End If
Any help would be very apprecciated.

Thanks in advance

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Perttu Pulkkinen | last post by:
Does anybody know a php-based image gallery, where final looks of the actual site would not be determined by the application? I mean that there would only be a php-library of objects/functions that...
8
by: Chris Dewin | last post by:
Hi. I run a website for my band, and the other guys want an image gallery. I'm thinking it would be nice and easy, if we could just upload a jpg into a dir called "gallery/". When the client...
13
by: Neo Geshel | last post by:
I have examined about 80+ different upload scripts on the 'net, both in VB and C#, and none seem to do what I need them to do. Perhaps someone here can point me somewhere that Google hasn't...
10
by: ste | last post by:
Hi there, I'm trying to query a MySQL database (containing image data) and to output the results in a HTML table of 3 columns wide (and however many rows it takes) in order to create a basic...
4
by: RE Kochanski | last post by:
I have attempted to use the CSS techniques from two or three sites to create a CSS only image gallery. I am muddling the affair by placing the thumbnails in one float, the page text in another...
1
by: gescom | last post by:
My goal is to create essentially two galleries on a single page, in which the first gallery determines what the second gallery displays. For instance, the first gallery refers to the contents of the...
0
by: numbnutz | last post by:
Hi, I am currently working on an XML Gallery for my girlfriend's brother who is a photographer. I have created a flash front end template and am using an XML database to load the images and...
5
by: dabhand | last post by:
Hi This page http://www.dabhand.co.nz/ayupdev/gallery-riders.html works great in IE but not in Firefox... any help would be appreciated. It refers to an external javascript file which I have...
10
by: cjparis | last post by:
Hello everyone. If anyone can give me a hand I would be gratefull Am doing a site which requires a moving element and have used DHTML to do it. Have a simple Browser detect script to sort IE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.