Create gallery layout with thumbnails using gridview?

I would like to know if anyone can help me solve a bit of a problem I have.
(I don't really use gridviews much as they have always confused me for some reason)

I am using LINQ, stored procedures and a gridview control to display a list of images, BUT what I would like to do it display the returned images in 3 or 4 columns by however many rows. I want to be able to add a link to the image to go to another page. I also only want to show the 'ImageFile' field of the returned data and not the other 2 fields (ID, Category) that will be returned, but I do want to use the ID field in the link on the image.

Can this be done in a GridView or am I better off using some other type of control to get the desired result?

Thanks in advance :)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
You would need to translate the underlying data source for the GridView into the form that you need, or you can use a DataList, where you can specify the RepeatColumns, RepeatDirection, and RepeatLayout.
clearchannelAuthor Commented:
A datalist sounds more like what I want. I'll give it a go and let you know if it works for me.
Bob LearnedCommented:

Simple DataList Demo

<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>
<script language="vb" runat="server">
  Sub Page_Load(sender as Object, e as EventArgs)
  End Sub
  Sub BindData()
    '1. Create a connection
    Dim myConnection as New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
    '2. Create the command object, passing in the SQL string
    Const strSQL as String = "sp_Popularity"
    Dim myCommand as New SqlCommand(strSQL, myConnection)
    'Set the datagrid's datasource to the datareader and databind
    dlPopularFAQs.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
  End Sub
<asp:DataList runat="server" id="dlPopularFAQs" 
                Width="85%" Border="1"
                Font-Name="Verdana" CellPadding="4"
                RepeatColumns="5" >
     <b>Question:</b><br />
     <%# DataBinder.Eval(Container.DataItem, "Description") %>
     <b>Views:</b><br />
     <%# DataBinder.Eval(Container.DataItem, "ViewCount", "{0:#,###}") %>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

clearchannelAuthor Commented:
Can i create the datatreader using LINQ and stored procedures in the same way?
Just i do not want to use bare sql commands in the page themselves for security reasons and I build my apps to be secure.

clearchannelAuthor Commented:
Ok I have the data list working, how would I show images in the list?
Bob LearnedCommented:
This article describes one way:

A Robust Image Gallery for ASP.NET

There are plenty of other examples, given the right Google search expression.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.