Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 748
  • Last Modified:

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

0
lapucca
Asked:
lapucca
  • 3
  • 2
1 Solution
 
MlandaTCommented:
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

0
 
lapuccaAuthor 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
0
 
lapuccaAuthor 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
0
 
MlandaTCommented:
The spaces are coming from a series of <br> tags after the "First Last Next" Prev buttons.
brtags.png
0
 
lapuccaAuthor Commented:
Thank you.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now