When on the first page, it is the front page of my website http://www.darvinkmanwah.com but then when it goes to page 2 of the data the URL does not change. How can I code it where when on page 2 the URL changes to reflect page 2 and so on.
Yah, it works, I'm gonna consider this resolved. I'm also planning on re-writing the URL of each artwork page so it looks cleaner in the URL display instead of a query string ...
Also just thought I'd share this with you guys ... Hey sjnaughton you were saying the add this "GridView1.PageIndex = 2; to my page but where exactly where you refering to place this code? Thanks
This is what I'm using for my reference at the moment for the re-writing of URLs:
I've been busy working on some other codes on my site and I haven't gotten to get around to this as yet. You can check out the site over at
http://www.darvinkmanwah.com for now and tell me what you think. I made the get alot of code working based on my other posts right here in asp.net.
Member
2 Points
82 Posts
Paging Through a ListView
Mar 20, 2012 04:48 AM|darvinkmanwah|LINK
Hey,
I'm currently pulling groups of 6 rows from my database with my DataPager looking like this:
When on the first page, it is the front page of my website http://www.darvinkmanwah.com but then when it goes to page 2 of the data the URL does not change. How can I code it where when on page 2 the URL changes to reflect page 2 and so on.
Feature Films, Movies, TV Show and Series, Short Films & Commercials in Vancouver
All-Star
17915 Points
5679 Posts
MVP
Re: Paging Through a ListView
Mar 20, 2012 12:42 PM|sjnaughton|LINK
1. is this relating to Dynmaic Data?
2. just set the curretn page like this
Always seeking an elegant solution.
Member
2 Points
82 Posts
Re: Paging Through a ListView
Mar 20, 2012 11:12 PM|darvinkmanwah|LINK
Hey,
1. Yes, this is Dynamic Data
2. How do I do that?
Thanks ...
Feature Films, Movies, TV Show and Series, Short Films & Commercials in Vancouver
Member
2 Points
82 Posts
Re: Paging Through a ListView
Mar 21, 2012 07:16 AM|darvinkmanwah|LINK
Hey,
Crazy enough I figured it out (sort of). I simply added a QueryStringField and used 'page' as the word to display, here is what the code looks like.
I'm not sure but is it correct? You can check it out here at the bottom of the page http://darvinkmanwah.com
Feature Films, Movies, TV Show and Series, Short Films & Commercials in Vancouver
All-Star
17915 Points
5679 Posts
MVP
Re: Paging Through a ListView
Mar 21, 2012 08:01 AM|sjnaughton|LINK
all you need to do to set the curretn page number of the pager is
this needs to be done after Page_Load event. but if your way is working that will be fine.
Always seeking an elegant solution.
Member
2 Points
82 Posts
Re: Paging Through a ListView
Mar 21, 2012 08:11 AM|darvinkmanwah|LINK
Yah, it works, I'm gonna consider this resolved. I'm also planning on re-writing the URL of each artwork page so it looks cleaner in the URL display instead of a query string ...
Thanks for the help by the way ...
Feature Films, Movies, TV Show and Series, Short Films & Commercials in Vancouver
All-Star
17915 Points
5679 Posts
MVP
Re: Paging Through a ListView
Mar 21, 2012 08:41 AM|sjnaughton|LINK
Please do a post on your blog if you have one and link back to this or another of your posts so we can all see how you did it :)
Always seeking an elegant solution.
Contributor
2006 Points
725 Posts
Re: Paging Through a ListView
Mar 21, 2012 08:50 AM|sanjayverma_mca|LINK
You Can do like this
<asp:DataList ID="dlPaging" runat="server" OnItemCommand="dlPaging_ItemCommand" RepeatDirection="Horizontal">
<ItemTemplate>
<asp:LinkButton ID="lnkbtnPaging" runat="server" class="paging" CommandArgument='<%#Eval("PageIndex")%>' CommandName="lnkbtnPaging" Text= '<%#Eval("PageText")%>' ></asp:LinkButton>
</ItemTemplate>
</asp:DataList>
PagedDataSource pds = new PagedDataSource();
pds.DataSource = ds.Tables[0].DefaultView;
pds.AllowPaging = true;
//pds.PageSize = Convert.ToInt16(ddlPageSize.SelectedValue);
pds.PageSize = 15;
pds.CurrentPageIndex = CurrentPage;
//lnkbtnNext.Enabled = !pds.IsLastPage;
//lnkbtnPrevious.Enabled = !pds.IsFirstPage;
listproduct.DataSource = pds;
listproduct.DataBind();
doPaging();
protected void dlPaging_ItemDataBound(object sender, DataListItemEventArgs e)
{
LinkButton lnkbtnPage = (LinkButton)e.Item.FindControl("lnkbtnPaging");
if (lnkbtnPage.CommandArgument.ToString() == CurrentPage.ToString())
{
lnkbtnPage.Enabled = false;
lnkbtnPage.Font.Bold = true;
}
}
private void doPaging()
{
DataTable dt = new DataTable();
dt.Columns.Add("PageIndex");
dt.Columns.Add("PageText");
for (int i = 0; i < pds.PageCount; i++)
{
DataRow dr = dt.NewRow();
dr[0] = i;
dr[1] = i + 1;
dt.Rows.Add(dr);
}
dlPaging.DataSource = dt;
dlPaging.DataBind();
}
protected void dlPaging_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName.Equals("lnkbtnPaging"))
{
CurrentPage = Convert.ToInt16(e.CommandArgument.ToString());
BindGrid();
}
}
protected void lnkbtnPrevious_Click(object sender, EventArgs e)
{
CurrentPage -= 1;
BindGrid();
}
protected void lnkbtnNext_Click(object sender, EventArgs e)
{
CurrentPage += 1;
BindGrid();
}
public int CurrentPage
{
get
{
if (this.ViewState["CurrentPage"] == null)
return 0;
else
return Convert.ToInt16(this.ViewState["CurrentPage"].ToString());
}
set
{
this.ViewState["CurrentPage"] = value;
}
}
All-Star
17915 Points
5679 Posts
MVP
Re: Paging Through a ListView
Mar 21, 2012 08:51 AM|sjnaughton|LINK
have you tested this with Dynamic Data?
Always seeking an elegant solution.
Member
2 Points
82 Posts
Re: Paging Through a ListView
Apr 05, 2012 04:12 AM|darvinkmanwah|LINK
Hey sanjayverma_mca, Have you tried the code?
Also just thought I'd share this with you guys ... Hey sjnaughton you were saying the add this "GridView1.PageIndex = 2; to my page but where exactly where you refering to place this code? Thanks
This is what I'm using for my reference at the moment for the re-writing of URLs:
http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
I've been busy working on some other codes on my site and I haven't gotten to get around to this as yet. You can check out the site over at http://www.darvinkmanwah.com for now and tell me what you think. I made the get alot of code working based on my other posts right here in asp.net.
You guys rocks ... Thanks ...
Feature Films, Movies, TV Show and Series, Short Films & Commercials in Vancouver
Contributor
2006 Points
725 Posts
Re: Paging Through a ListView
Apr 07, 2012 12:32 AM|sanjayverma_mca|LINK
Hi darvinkmanwah
Yes I try it even though I am using the code and it's working fine.i hop this code is also working for you and all.
Member
2 Points
82 Posts
Re: Paging Through a ListView
Apr 07, 2012 01:08 AM|darvinkmanwah|LINK
Thanks alot,
I ended up using another method and it worked for what I wanted. I simply added a QueryStringField and it worked.
<asp:DataPager ID="DataPager1" runat="server" PageSize="7" QueryStringField="page">
You can see the result of the URL here: http://darvinkmanwah.com/digital-playground/artwork/archive.aspx?page=2
Thanks again for all the help ...
Feature Films, Movies, TV Show and Series, Short Films & Commercials in Vancouver
All-Star
17915 Points
5679 Posts
MVP
Re: Paging Through a ListView
Apr 07, 2012 01:23 PM|sjnaughton|LINK
Always seeking an elegant solution.
Member
2 Points
82 Posts
Re: Paging Through a ListView
Apr 17, 2012 01:54 AM|darvinkmanwah|LINK
Ok great ... thanks ...
Check out the page now, it works ...
http://darvinkmanwah.com/digital-playground/artwork/archive.aspx?page=2#Top
Thanks ...
Feature Films, Movies, TV Show and Series, Short Films & Commercials in Vancouver
Member
179 Points
790 Posts
Re: Paging Through a ListView
May 14, 2013 12:30 AM|atul2430|LINK
Hey darvin..
i tried this into my script its not working for me..on click on next records are not displaying.
actully i am bin
ding listview in dropdownchange event..
Member
179 Points
790 Posts
Re: Paging Through a ListView
May 14, 2013 12:44 AM|atul2430|LINK
url getting change but data is same for all pages...
i am binding data on dropdownlist changeevent..
Member
2 Points
82 Posts
Re: Paging Through a ListView
Jun 24, 2013 01:49 PM|darvinkmanwah|LINK
Hey atul2430,
Can you insert the link for your page to have a look at, Thanks ...
Feature Films, Movies, TV Show and Series, Short Films & Commercials in Vancouver