How would you use a repeater within a dataset? I'm trying to display pictures, while only displaying 25 pictures per page. I want to be able to enable paging. How would I do this?
Printable View
How would you use a repeater within a dataset? I'm trying to display pictures, while only displaying 25 pictures per page. I want to be able to enable paging. How would I do this?
Use a Datalist instead...
you can set the columns across through a property.
You can then go a google search for 'DataList paging', you'll get good articles like http://www.dotnetjunkies.com/Tutoria...2516BF05B.dcik
I mention using DataList because it passes the html validation, whereas Repeaters usually don't.
Use a datagrid.
Bind to query like this
turn off the detect colums and make it bind to the row and the image name or something. In the On/ItemDataBind event replace the text for column 2 (index 1) clear the text and add an img control with src set to you image load page or the real url if your pics or not in the dbCode:(
@PageSize int,
@PageIndex int
)
AS
CREATE TABLE #TempTable
(
ImageRowID int IDENTITY(1,1),
ImageKey char(36)
)
INSERT INTO #TempTable (ImageKey)
SELECT Guid FROM Images
SELECT #TempTable.ImageRowID, Images.*
FROM #TempTable
INNER JOIN Images ON
Images.Guid = #TempTable.ImageKey
WHERE ImageRowID > @PageSize * @PageIndex
AND ImageRowID <= @PageSize * (@PageIndex+1)
ORDER BY #TempTable.ImageRowID
RETURN
If that doesn't make since let me know I just woke up
Hi!
I want to add on this question. What if I want to create a simple repeater that renders a table x times y cells filled with images like a photo gallery. I get the image using an ashx http module. How would this be possible?
I have thought about the idea about creating the itemtemplate with 3 or 4 images, but then I always get the table 3 or 4 cells wide. What if the last image is on cell 1 (from the left). Then I must detect this somehow and remove the images, so they don't show the ugly red cross.
Anyone has any ideas? I did a google and found very little regarding this. I thought it was a very common problem...
kind regards
Henrik
Forget my question.... dah, I will just use a DataList control.
cheers/Henrik
DataList is best for this purpose. If you have the ListView, that's the same but slightly better and meant for galleries or a dynamic number of cells rather than rows.