2013-03-23 98 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