I have had success doing this.
What you have to do is copy the <ItemTemplate>
content from the existing datalist then delete the datalist and create a gridview and then paste the code into that. In fact, i'm working on a realtor web site not only adding paging, but dynamic sorting based on a variety of dropdowns. For
your goal, try this---
STEPS:
From the existing listview, copy <ItemTemplate> .....original photoalbum code here........</ItemTemplate>
Delete the listview
Create a new datagrid
In the new gridview you'll need to add <asp:TemplateField>
</asp:TemplateField>
Paste <ItemTemplate> .....original photoalbum code here........</ItemTemplate>
inside the <asp:TemplateField> tags. Should look like something like this (configured to your datasource
of course):
the first time i did it i did not have the <columns> tag and when i changed to the design view it gave me the following error
Error Creating Control-content 1
Type 'System.Web.UI.WebControls.'GridView'does not have a public property named 'Item Template'\
I then added the columns tag and it would not let me go to the design view and left the following error
never mind that error there was just an error i did something else I remove your code and configured my datasource
I ran my website to a browser and i was able to enter my site but when i went into the photo album of choice i got the following error
Server Error in '/ClubWebSite1' Application.
Compilation Error
Description:
An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30451: Name 'DataList2' is not declared.
Source Error:
Line 15:
Line 16: Protected Sub FormView2_PageIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Line 17: DataList2.SelectedIndex = FormView2.PageIndex
Line 18: FormView1.ChangeMode(FormViewMode.ReadOnly)
Line 19: End Sub
now what do i do. keep in mind while configuring my data source it was showing me my photo when i hit test query in the configure data source section of the gridview section
ruinedmind
Member
247 Points
54 Posts
Paging in the Photo Section
Feb 22, 2007 07:29 PM|LINK
I have created multiple albums and the paging doesn't seem to work...I would like to only have 6 albums and the rest on the next page.
Thanks,
Grant
iaingwilson
Member
4 Points
3 Posts
Re: Paging in the Photo Section
Mar 11, 2007 05:06 AM|LINK
I have had success doing this.
What you have to do is copy the <ItemTemplate> content from the existing datalist then delete the datalist and create a gridview and then paste the code into that. In fact, i'm working on a realtor web site not only adding paging, but dynamic sorting based on a variety of dropdowns. For your goal, try this---
STEPS:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="albumid" DataSourceID="ObjectDataSource1" AllowSorting="True" PageSize="6">
<Columns> <asp:TemplateField><ItemTemplate> original photoalbum code listview here</ItemTemplate>
</asp:TemplateField> </Columns> <PagerSettings FirstPageText="First" LastPageText="Last" Mode="NumericFirstLast" PageButtonCount="3" Position="TopAndBottom" /></asp:GridView>
I can't remember if this was the page i had to jack with the sproc or not, it's late, that's all i got.
iaingwilson
Member
4 Points
3 Posts
Re: Paging in the Photo Section
Mar 11, 2007 05:10 AM|LINK
2. Delete the Datalist
3. Create a new Gridview
sorry, really tired...
razzak25000@...
Member
4 Points
5 Posts
Re: Paging in the Photo Section
Feb 26, 2009 10:28 PM|LINK
I get errors with this can you help with it..
I copied the content from my DataList and then deleted it.
I then added a GridView and posted this in the code
<asp:GridView ID="GridView1" runat="server" Height="364px" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="191px"> <Columns> <ItemTemplate> <asp:ImageButton ID="ImageButton1" ImageUrl='<%# "imagefetch.ashx?size=1&imageid=" & Cstr(Eval("id")) %>' runat="server" CommandName="select" /><br /> <asp:Label Text='<%# Eval("title") %>' runat="server" ID="titleLabel" />
</Columns> </ItemTemplate>
</asp:GridView>the first time i did it i did not have the <columns> tag and when i changed to the design view it gave me the following error
Error Creating Control-content 1
Type 'System.Web.UI.WebControls.'GridView'does not have a public property named 'Item Template'\
I then added the columns tag and it would not let me go to the design view and left the following error
never mind that error there was just an error i did something else I remove your code and configured my datasource
I ran my website to a browser and i was able to enter my site but when i went into the photo album of choice i got the following error
Server Error in '/ClubWebSite1' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.Compiler Error Message: BC30451: Name 'DataList2' is not declared.
Source Error:
now what do i do. keep in mind while configuring my data source it was showing me my photo when i hit test query in the configure data source section of the gridview section