Link to home
Start Free TrialLog in
Avatar of lapucca
lapucca

asked on

Problem working with Datapager

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

Avatar of Mlanda T
Mlanda T
Flag of South Africa image

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

Avatar of lapucca
lapucca

ASKER

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
Avatar of lapucca

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Mlanda T
Mlanda T
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lapucca

ASKER

Thank you.