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 :)
clearchannelAsked:
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.
0
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.
0
Bob LearnedCommented:
Example:

Simple DataList Demo
http://aspnet.4guysfromrolla.com/demos/dlExampleRepeatColumns.aspx


<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>
<script language="vb" runat="server">
  Sub Page_Load(sender as Object, e as EventArgs)
    BindData()
  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
    myConnection.Open()
    dlPopularFAQs.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
    dlPopularFAQs.DataBind()	
  End Sub
</script>
 
<asp:DataList runat="server" id="dlPopularFAQs" 
                Width="85%" Border="1"
                HorizontalAlign="Center"
                Font-Name="Verdana" CellPadding="4"
                Font-Size="10pt"
                RepeatColumns="5" >
   <ItemTemplate>
     <b>Question:</b><br />
     <%# DataBinder.Eval(Container.DataItem, "Description") %>
     <p>
     <b>Views:</b><br />
     <%# DataBinder.Eval(Container.DataItem, "ViewCount", "{0:#,###}") %>
   </ItemTemplate>
</asp:DataList>	

Open in new window

0

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
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

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.

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

A Robust Image Gallery for ASP.NET
http://aspnet.4guysfromrolla.com/articles/081303-1.aspx

There are plenty of other examples, given the right Google search expression.
0
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
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.