The problem is upon clicking the next button for the first time nothing happens.But if the next button is clicked second time, then only the second page appears.
What control are you paging? I see nothing for PagedControlID? Or if you trying to control a page then you need QueryStringField. I see nothing in either case.
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
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: CS1061: 'DirectoryContent_DefaultTag' does not contain a definition for 'DataPager1' and no extension method 'DataPager1' accepting a first argument of type 'DirectoryContent_DefaultTag' could be found (are you missing a using
directive or an assembly reference?)
Source Error:
Line 94: // Needs improvement
Line 95: //ListView1.EditIndex = -1;
Line 96: this.DataPager1.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
Line 97:
Line 98: }
The DataPager is probably in a NamingContainer. If you put it in the ListView try, for example in a handler for the ListView PagePropertiesChanging event:
DataTable oRoles = new DataTable();
DataColumn oRolesColumn = new DataColumn("RoleName");
oRoles.Columns.Add(oRolesColumn);
string[] sArry = Roles.GetAllRoles();
for (int i = 0; i < sArry.Length; i++)
{
oRoles.Rows.Add(sArry[i]);
}
lvRoles.DataSource = oRoles;//lvRoles is the name of listviewcontrol
lvRoles.DataBind();
asubiswal
0 Points
3 Posts
Problem with DataPager
May 13, 2008 08:29 AM|LINK
I am facing a problem while using DataPager with ListView.
I am using it as follows:
<asp:DataPager ID="DataPager1" runat="server"> <Fields> <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" /> <asp:NumericPagerField /> </Fields> </asp:DataPager>The problem is upon clicking the next button for the first time nothing happens.But if the next button is clicked second time, then only the second page appears.
Please help.
DataPager Problem
aamador
Contributor
5211 Points
1107 Posts
Re: Problem with DataPager
May 13, 2008 09:32 AM|LINK
What control are you paging? I see nothing for PagedControlID? Or if you trying to control a page then you need QueryStringField. I see nothing in either case.
asubiswal
0 Points
3 Posts
Re: Problem with DataPager
May 14, 2008 09:44 AM|LINK
Sorry this is the code for the data pager and the paged control id is the listview.
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1" >
<Fields> <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" /> <asp:NumericPagerField /> </Fields> </asp:DataPager>I am binding the list view in the code behind by fetching some data from the database
DataPager Problem
Samu Zhang -...
All-Star
62163 Points
6101 Posts
Re: Problem with DataPager
May 15, 2008 03:01 AM|LINK
Hi asubiswal ,
It works fine on my pc.
You can write some code in PagePropertiesChanging event of Listview contorl if it still does not work.
protected void ListView1_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e) { this.DataPager1.SetPageProperties(e.StartRowIndex, e.MaximumRows, false); }Samu Zhang
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
a_romka
Member
27 Points
17 Posts
Re: Problem with DataPager
May 19, 2008 07:37 AM|LINK
just do
<
asp:DataPager ... OnPreRender="DataPager1_PreRender">and in code behind:
protected
void DataPager1_PreRender(object sender, EventArgs e) {DataPager1.DataSource = ..whaterver source...;
DataPager1.DataBind();
}
that fixed everything for me
Melbu
Member
43 Points
8 Posts
Re: Problem with DataPager
May 19, 2008 08:00 AM|LINK
Hi,
the problem is widely known. Call in the PreRender method of your Page the function
of your ListView.
Best Regards
Melbu
aDelfino69
Member
4 Points
4 Posts
Re: Problem with DataPager
Jun 18, 2008 03:36 PM|LINK
Hi
I get this :
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: CS1061: 'DirectoryContent_DefaultTag' does not contain a definition for 'DataPager1' and no extension method 'DataPager1' accepting a first argument of type 'DirectoryContent_DefaultTag' could be found (are you missing a using directive or an assembly reference?)
Source Error:
WHy ?
Code :
<asp:DataPager OnPreRender="DataPager1_PreRender" ID="DataPager1" runat="server" PagedControlID="ListView1" PageSize="20" > <Fields> <asp:NextPreviousPagerField ButtonType="Button" FirstPageText="Primo" ShowFirstPageButton="false" ShowNextPageButton="False" ShowPreviousPageButton="False" /> <asp:NumericPagerField /> <asp:NextPreviousPagerField ButtonType="Button" LastPageText="Ultimo" ShowLastPageButton="false" ShowNextPageButton="False" ShowPreviousPageButton="False" /> </Fields> </asp:DataPager>and:
protected void ListView1_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e){
this.DataPager1.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);}
It's quite odd ?!
I cannot PageSize works on 20 pages.. I used a codebehind to popolate the listview.
Any suggestion ?
Mufasa245
Member
202 Points
49 Posts
Re: Problem with DataPager
Aug 15, 2008 06:03 PM|LINK
The DataPager is probably in a NamingContainer. If you put it in the ListView try, for example in a handler for the ListView PagePropertiesChanging event:
Mufasa
Maharkhan
Member
34 Points
18 Posts
Re: Problem with DataPager
Dec 19, 2008 09:40 AM|LINK
Hi Samu Zhang,
Your given code is not working in my application i have same problem as asubsal.
ListView :
<asp:ListView ID="ListViewGroups" runat="server" ItemPlaceholderID="linksHolder" OnPagePropertiesChanging="ListViewGroups_PagePropertiesChanging" DataKeyNames="" >
<LayoutTemplate>
<ItemTemplate>
<asp:ListView ID="ListView1" runat="server" ItemPlaceholderID="itemPlaceHolder">
<LayoutTemplate><ItemTemplate></ItemTemplate></LayoutTemplate>
</ asp:ListView>
</ItemTemplate>
</LayoutTemplate>
</ asp:ListView>
DataPager:
<asp:DataPager ID="dPagerGroups" runat="server" PageSize="5" PagedControlID="ListViewGroups">
<Fields>
<asp:NextPreviousPagerField ShowFirstPageButton="true" ShowLastPageButton="false"
ShowNextPageButton="false" ShowPreviousPageButton="true" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField ShowFirstPageButton="false" ShowLastPageButton="true"
ShowNextPageButton="true" ShowPreviousPageButton="false" />
</Fields>
</asp:DataPager>
This is not working ....
Database connection and all other steps are correct.... just paging is not working..... plz give reply as soon as possible...
sabbirspider
Member
125 Points
132 Posts
Re: Problem with DataPager
Nov 04, 2009 03:58 AM|LINK
Hi all,
I think you all are Setting datasouce of listview control by custom datasource from page_load event.i.e..
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
FillRoles();//
}
}
protected void FillRoles()
{
DataTable oRoles = new DataTable();
DataColumn oRolesColumn = new DataColumn("RoleName");
oRoles.Columns.Add(oRolesColumn);
string[] sArry = Roles.GetAllRoles();
for (int i = 0; i < sArry.Length; i++)
{
oRoles.Rows.Add(sArry[i]);
}
lvRoles.DataSource = oRoles;//lvRoles is the name of listviewcontrol
lvRoles.DataBind();
}
like this...if so just do this..
protected void lvRoles_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
DataPager1.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
FillRoles();
}
just call the FillRoles() function again...this will solve your problem