We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Problem working with Datapager

lapucca
lapucca asked
on
Medium Priority
805 Views
Last Modified: 2012-05-11
Hi, i'm using asp.net 3.5, C#
I have a user control that uses DataPager and Liveview to display data that is return as a dataset table from a web service call.  The listview datasource is bind to the return datatable.  
1.  However, my Datapage doesn't seem to work when i click on any of the page it refreshes the page but still display the same data.
2.  There is a big gap about 2,3 inches before the listview starts displaying the data.  This gap was not there when I was uss DataList control to implement this.  
How can I correct these 2 problems?  thank you.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="PhysiciansSearchResult.ascx.cs" Inherits="SearchPhysicians.USCUserControls.PhysiciansSearchResult" %>
<%--<link href="CSS/PhysicianResults.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
--%>
<%--<script type="text/javascript">

$(document).ready(function(){
    $("#resultLabel").animate( { width: "90%" }, { queue: false, duration: 3000 })
     .animate({ fontSize: "36px" }, 1500 )
     .animate({ borderRightWidth: "15px" }, 1500 );
});

</script>--%>
<%--<span id="resultLabel" class="ResultTitle">Find a Doctor Search Results</span>--%>

  <table width="100%">

    <tr>
      <td>
        <asp:DataPager ID="dpResult" runat="server" PagedControlID="lvSearchResult">
        <Fields>
            <asp:NextPreviousPagerField ShowFirstPageButton="True" 
                ShowLastPageButton="True" />
        </Fields>
      </asp:DataPager>
  <asp:ListView ID="lvSearchResult" runat="server" ondatabound="lvSearchResult_DataBound">
        <LayoutTemplate>
            <table cellpadding="10" style="font: 10pt verdana"><tbody>
                <tr id="itemPlaceholder" runat="server"></tr>
            </tbody></table>
        </LayoutTemplate>
        
       <ItemSeparatorTemplate>
          <br />
       </ItemSeparatorTemplate>        
        
        <ItemTemplate>
              <tr>
                <td valign="top">   
                    <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl='<%# SetImageURL(Eval("PhotoPath")) %>' Width="50" AlternateText="Photo" BorderStyle="None" BorderWidth="1" />
              
                </td>
                <td valign="top">
                  <asp:linkbutton ID="lkbtnDocotrName" Text='<%# DataBinder.Eval(Container.DataItem, "FullName") %>' CommandName="Select" runat="server" 
                    CommandArgument="personId" ForeColor="#CC0000" PostBackUrl="~\SearchResults.aspx" />
                  <br/>
                  <%# Eval("Department_Name")%>
                  <br/><p>
                    <asp:Label ID="lbSpecialties" Text='<%# DataBinder.Eval(Container.DataItem, "Specialties") %>' runat="server" Width="4in"></asp:Label>
                  <br /> 
                    <asp:Label ID="lbPhone" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Coord_Phone") %>'></asp:Label>

                    <asp:HyperLink NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "email_address", "mailto:{0}") %>' Text='<%# DataBinder.Eval(Container.DataItem, "email_address") %>' runat="server" ID="hlEmail"></asp:HyperLink>
                    </p>
                </td>
              </tr>
        </ItemTemplate>
        <AlternatingItemTemplate>
              <tr style="background-color:#EFEFEF">
                <td valign="top">   
                    <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl='<%# SetImageURL(Eval("PhotoPath")) %>' Width="50" AlternateText="Photo" BorderStyle="None" BorderWidth="1" />
              
                </td>
                <td valign="top">
                  <asp:linkbutton ID="lkbtnDocotrName" Text='<%# DataBinder.Eval(Container.DataItem, "FullName") %>' CommandName="Select" runat="server" 
                    CommandArgument="personId" ForeColor="#CC0000" PostBackUrl="~\SearchResults.aspx" />
                  <br/>
                  <%# DataBinder.Eval(Container.DataItem, "Department_Name")%>
                  <br/><p>
                    <asp:Label ID="lbSpecialties" Text='<%# DataBinder.Eval(Container.DataItem, "Specialties") %>' runat="server" Width="4in"></asp:Label>
                  <br /> 
                    <asp:Label ID="lbPhone" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Coord_Phone") %>'></asp:Label>

                    <asp:HyperLink NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "email_address", "mailto:{0}") %>' Text='<%# DataBinder.Eval(Container.DataItem, "email_address") %>' runat="server" ID="hlEmail"></asp:HyperLink>
                    </p>
                </td>
              </tr>
        </AlternatingItemTemplate>
</asp:ListView>
          <asp:DataPager ID="DataPager1" runat="server" PagedControlID="lvSearchResult" PageSize="10">
              <Fields>
                  <asp:NextPreviousPagerField PreviousPageText="&lt;&lt;  " 
                      ShowNextPageButton="False" />
                  <asp:NumericPagerField />
                  <asp:NextPreviousPagerField NextPageText="  &gt;&gt;" 
                      ShowPreviousPageButton="False" />
              </Fields>
          </asp:DataPager>
</td>
</tr>
</table>

Open in new window

Comment
Watch Question

CERTIFIED EXPERT

Commented:
1.  However, my Datapage doesn't seem to work when i click on any of the page it refreshes the page but still display the same data.

how are you loading the data into the datapage? if you are databinding in say Page_Load, just make sure that you are checking the value of Page.IsPostback i.e.
if not Page.IsPostback then ...load and bind the default data etc

Open in new window

Author

Commented:
Hi, I am checking for that and data is displayed for the 1st page correctly.  It's just the datapager isn't working. Thank you.  Also, about the gap under the first datapager control and before the listview.  Here is the html code from FF View Soruce attached.
SearchResults.html

Author

Commented:
Item 2, the big gap space above the listview is resolved.  Now, it's only the datapager not working.  When I click on any of the page or next button, the same records are displayed.  I noticed that there is a post back but comes back with the same records displayed.  Attached is my user control's back end code.  Could my problem comes from this is a user control?  Thanks.
Thanks.
PhysiciansSearchResult.ascx.cs
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Thank you.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.