Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Image gallery with DataGrid

Reply
Thread Tools

Image gallery with DataGrid

 
 
=?Utf-8?B?bHR0MTk=?=
Guest
Posts: n/a
 
      06-14-2005
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?RWx0b24gVw==?=
Guest
Posts: n/a
 
      06-14-2005
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
http://www.velocityreviews.com/forums/(E-Mail Removed)




"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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Image gallery query KiwiBrian HTML 2 05-01-2007 08:04 AM
Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell www.web20developers.com Java 0 10-12-2006 09:39 PM
Image Gallery with support for sale of images ? Dougbert ASP .Net 0 09-28-2005 08:32 PM
Create an Image Gallery with FILES web directory and names of files in SQL server news.microsoft.com ASP .Net 1 02-27-2005 03:44 AM
Digital Image Gallery Tomasz L. Czarnecki Digital Photography 1 02-04-2004 11:38 AM



Advertisments