Hi sir,
I am using listview control in asp.net and in table are only four rows as you can see in below picture. I want to hide 'DataPager' if rows are less than 'PageSize'. please suggest me.

Code
<asp:ListView ID="Listv1" runat="server" GroupPlaceholderID="groupPlaceHolder1"
ItemPlaceholderID="itemPlaceHolder1" OnPagePropertiesChanging="OnPagePropertiesChanging">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="groupPlaceHolder1"></asp:PlaceHolder>
<div class="cd-pagination">
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="Listv1" PageSize="10">
<Fields>
<asp:NextPreviousPagerField ButtonCssClass="prev_but" ButtonType="Link"
ShowFirstPageButton="false"
ShowLastPageButton="false" ShowNextPageButton="false" />
<asp:NumericPagerField
CurrentPageLabelCssClass="current"
NextPreviousButtonCssClass="next_but" ButtonCount="5" />
<asp:NextPreviousPagerField ButtonType="Link" ButtonCssClass="next_but"
ShowLastPageButton="false" ShowNextPageButton="true"
ShowPreviousPageButton="false" />
</Fields>
</asp:DataPager>
</div>
</LayoutTemplate>
<GroupTemplate>
<asp:PlaceHolder runat="server" ID="itemPlaceHolder1"></asp:PlaceHolder>
</GroupTemplate>
<ItemTemplate>
<div class="col-md-12 padding0">
<div class="sightseeeing_listing">
<div class="col-md-2">
<img class="listing_pic" src='<%# Eval("imagePath") %>'>
</div>
<div class="col-md-8">
<h3> <%# Eval("activityName") %> </h3>
<div class="margin_top6"> <%# Eval("introduction").ToString().PadRight(186).Substring(0, 186).TrimEnd()%> </div>
<div class="line_h27 margin_top10">
<label class="pull-left margin_right_10"> <span class="location_icon pull-left"> </span> <%# Eval("cityName")%>, <%# Eval("countryName")%></label>
<label class="pull-left margin_right_10"><span class="category_icon pull-left"> </span> <%# Eval("category")%> </label>
<label class="pull-left"> <span class="duration_icon pull-left"> </span> <%# Eval("durationHours")%></label>
<div class="clearfix"> </div>
</div>
</div>
<div class="col-md-2 padding0">
<div> Starting From </div>
<h3 class="fcol_pink">
<asp:Label ID="lblCurrency" runat="server" Text='AED'></asp:Label> <%# DataBinder.Eval(Container.DataItem, "amount", "{0:0.00}")%>
</h3>
<div class=" fcol_gray_d">per person </div>
<%--<div class="margin_top6"> <a href="SightseeingDetails3.aspx?id=<%# Eval("Id") %>" class="btn but_p"> View Details </a> </div>--%>
<div class="margin_top6"> <a href="SightseeingDetails.aspx?id=<%# Eval("Id")%>" class="btn but_p"> View Details </a> </div>
</div>
<div class="clearfix"> </div>
</div>
<div class="clearfix"> </div>
</div>
</ItemTemplate>
</asp:ListView>
protected void Page_Load(object sender, EventArgs e) {
if (!this.IsPostBack)
{
this.BindListView();
}
}
private void BindListView()
{
string constr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select * from activity";
cmd.Connection = con;
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
sda.Fill(dt);
Listv1.DataSource = dt;
Listv1.DataBind();
//if (dt.Rows.Count > 5)
//{
//}
}
}
}
}
protected void OnPagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
(Listv1.FindControl("DataPager1") as DataPager).SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
this.BindListView();
}
regards
firoz