This is a migrated thread and some comments may be shown as answers.

Datapager does not change the results shown

4 Answers 92 Views
ListView
This is a migrated thread and some comments may be shown as answers.
John Smith
Top achievements
Rank 1
John Smith asked on 13 Sep 2010, 06:21 AM
The page tabs show up on the datapager, and only the first 10 items are shown.   When I click on one of the page numbers though, a) the results don't change; b) the new page number is not highlighted (when I click a second time, it is highlighted however but the results still don't change).

Any help would be much appreciated.

My aspx markup:
<table border="0" cellspacing="0" cellpadding="4">
    <tr>
        <td>
            <telerik:RadTextBox ID="txtInstitutionName" runat="server" Columns="30" /><asp:RequiredFieldValidator
                ID="RequiredFieldValidator1" ControlToValidate="txtInstitutionName" runat="server"
                ErrorMessage="*" />
        </td>
        <td>
            <asp:Button ID="btnSearch" runat="server" Text="Search" />
        </td>
    </tr>
</table>
<telerik:RadListView ID="listInstitutions" runat="server" AllowPaging="true">
    <ItemTemplate>
        <li>
            <%# Eval("InstitutionName") %></li>
    </ItemTemplate>
    <EmptyDataTemplate>
        No financial institution was found.</EmptyDataTemplate>
    <LayoutTemplate>
        <ul>
            <li id="itemPlaceholder" runat="server" />
        </ul>
        <telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="listInstitutions" PageSize="10" >
            <Fields>
                <telerik:RadDataPagerButtonField FieldType="Numeric" />
            </Fields>
        </telerik:RadDataPager>
    </LayoutTemplate>
</telerik:RadListView>


My code for clicking the submit button:
InstitutionContext = New ProjectTobyEntities()
 
Dim institutionQuery As ObjectQuery(Of Institution) = _
    From i In InstitutionContext.Institutions _
    Where i.InstitutionName.Contains(txtInstitutionName.Text) And i.Active = True
    Select i
 
listInstitutions.DataSource = CType(institutionQuery, ObjectQuery).Execute(MergeOption.NoTracking)
listInstitutions.DataBind()

4 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 13 Sep 2010, 07:42 AM
Hi John,

Please verify that you have correctly configure RadListView to use advanced data-binding (through NeedDataSource).

Regards,
Rosen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
John Smith
Top achievements
Rank 1
answered on 13 Sep 2010, 08:47 AM
Hi Rosen

Well, no I hadn't.   I believe I have now though:

I added this sub:
Private Sub listInstitutions_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadListViewNeedDataSourceEventArgs) Handles listInstitutions.NeedDataSource
    InstitutionContext = New ProjectTobyEntities()
 
    Dim institutionQuery As ObjectQuery(Of Institution) = _
        From i In InstitutionContext.Institutions _
        Where i.InstitutionName.Contains(txtInstitutionName.Text) And i.Active = True
        Select i
 
    listInstitutions.DataSource = CType(institutionQuery, ObjectQuery).Execute(MergeOption.NoTracking)
End Sub

And also modified the markup like this:
<telerik:RadListView ID="listInstitutions" runat="server" AllowPaging="true"
    OnNeedDataSource="listInstitutions_NeedDataSource" DataKeyNames="InstitutionId" >

But I now get a compilation error: BC30456: 'listInstitutions_NeedDataSource' is not a member of 'ASP.accountadd_aspx'.

Any further help about where I've gone wrong would be greatly appreciated.  Regards, John
0
John Smith
Top achievements
Rank 1
answered on 13 Sep 2010, 09:14 AM
Solved!  I managed to solve this by removing 

OnNeedDataSource="listInstitutions_NeedDataSource"

from the markup.   I don't know if this is a problem with the example code, or just my not understanding the code well enough.

Thanks for your help, Rosen.

Regards, John
0
Rosen
Telerik team
answered on 13 Sep 2010, 09:19 AM
Hello John,

As you may know in order code-behind methods/properties to be accessible from page's markup their accessibility level should be at least protected.
Also you do not need to hook the handler in the markup as you have already set it in the code behind.

All the best,
Rosen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ListView
Asked by
John Smith
Top achievements
Rank 1
Answers by
Rosen
Telerik team
John Smith
Top achievements
Rank 1
Share this question
or