2013-03-23 92 views
0

你好家伙这是我的产品显示页面。我已经包含了Datapager控件。 所有的产品都显示在单页...但显示数据寻呼机不显示

页面

这里是我的代码之间导航在不寻呼机控制....需要帮助解决这个代码

  <asp:ListView runat="server" ID="listView" GroupItemCount="4"> 
     <LayoutTemplate> 
      <div style="width: 650px;"> 
       <asp:PlaceHolder runat="server" ID="groupPlaceHolder" /> 
      </div> 
     </LayoutTemplate> 
     <GroupTemplate> 
      <div style="clear: both;"> 
       <asp:PlaceHolder runat="server" ID="itemPlaceHolder" /> 
      </div> 
     </GroupTemplate> 
     <ItemTemplate> 
      <div class="productItem"> 
       <img src='<%# Eval("p_location") %>' height="120" width="120" alt="Not found" /> 
       <div> 
        <b> 
         <%# Eval("p_name") %></b></div> 
       <div> 
        Price: $<%# Eval("p_price") %></div> 

      </div> 
     </ItemTemplate> 
     <ItemSeparatorTemplate> 
      <div class="itemSeparator"> 
      </div> 
     </ItemSeparatorTemplate> 
     <GroupSeparatorTemplate> 
      <div class="groupSeparator"> 
      </div> 
     </GroupSeparatorTemplate>   
    </asp:ListView> 
    <div class="datapager"> 
     <asp:DataPager ID="DataPager1" PageSize="8" PagedControlID="listView" runat="server"> 
      <Fields> 
       <asp:NextPreviousPagerField ButtonType="Button" /> 
      </Fields> 
     </asp:DataPager> 
    </div> 

代码隐藏c#:

 protected void Page_Load(object sender, EventArgs e) 
    { 
    SqlConnection conn = new SqlConnection("ConnectionString"); 
    conn.Open(); 
    SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM p_detail", conn); 
    DataTable dt = new DataTable(); 
    da.Fill(dt); 
    conn.Close(); 
    listView.DataSource = dt; 
    listView.DataBind(); 
    } 
+0

是不显示的数据,在全部或只是当你点击页面的事件? – polin 2013-03-23 06:39:39

+0

它在单个页面中显示所有数据,但页面控制不显示用于在页面之间导航 – John 2013-03-23 06:52:44

回答

0

您需要创建该列表视图的事件。
1.转到listview属性
2.双击名为“PagePropertyChanging”的事件。这将创建如onpagepropertieschanging="ListView_PagePropertiesChanging"
3.source代码

protected void ListView_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e) 

{ 
    DataPager1.SetPageProperties(e.StartRowIndex, e.MaximumRows, false); 
    ListView.DataSource = dt; 
    ListView.DataBind(); 
} 
+0

我已尝试过您的代码...但它现在不显示任何产品.... :( – John 2013-03-23 07:09:25

+0

好吧。您有多少行有多少网页显示? – polin 2013-03-23 07:17:55

+0

我有我的表16行......它显示了所有的产品..This是,我发现First   Previous   Next   Last  代码在我的页面源代码... – John 2013-03-23 09:21:15