Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LIstview with datapager

Status
Not open for further replies.

M8KWR

Programmer
Aug 18, 2004
864
GB
I have got a listview with a datapager, the data is loading correctly.

But when you are presented with the next previous and pages, you have to click them twice before the page will properly reload the data.

when you press them once the page does reload, but from the users point of view the same data is given back.

on the aspx page this is all the code i have

Code:
   <form id="form1" runat="server">
    <div>
           <asp:DataPager ID="DataPager1" 
                       PagedControlID="ListView1" 
                       PageSize="5" runat="server">
           <Fields>
           <asp:NextPreviousPagerField />
           
            <asp:NumericPagerField />                          
           </Fields>
        </asp:DataPager>     <br />
       

        <asp:ListView ID="ListView1" runat="server" >
         <LayoutTemplate>
          <br /><br />Test Listview<br /><br />
          <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
        </LayoutTemplate>    
        
        <ItemTemplate>
                 <%#DataBinder.Eval(Container.DataItem, "Product_ID")%> 
        </ItemTemplate>
        <ItemSeparatorTemplate>
            <br />
            <hr />
            <br />
        </ItemSeparatorTemplate>
        </asp:ListView>

And the VB code behind is
Code:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim HashTable As New Hashtable
        Dim Cat_label As New Label
        Dim sql_string As String = Nothing


        HashTable.Add("?item_id", "220")

        sql_string = "SELECT products.Product_ID,  products.Product_name,  products.Product_Description,  products.Main_Description,  products.Price,  products.Image_URL,  products.Weight,  products.Supplier_ID, products.out_of_stock  FROM    (product_category product_category  INNER JOIN products products  ON (product_category.Product_ID = products.Product_ID))  INNER JOIN category category  ON (category.Category_ID = product_category.Category_ID)  WHERE (category.Category_ID = ?item_id) and products.enabled=-1"

        Dim DataTable_new As DataTable = FillMySQL(sql_string, HashTable)

        ListView1.DataSource = DataTable_new
        ListView1.DataBind()


    End Sub

Just wondered if there was something i was doing wrong?

Many thanks for reading the post.
 
If i put my page_load code into the If Not Page.IsPostBack i am still getting the same results!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top