Paging and datalist?

Rate It (2)

Last post 03-08-2007 6:39 PM by Lorenzo Battaglia. 3 replies.

Sort Posts:

  • Paging and datalist?

    12-30-2006, 8:36 AM
    • Loading...
    • mfarshadmehr
    • Joined on 09-09-2006, 2:45 PM
    • Neyshabour , Yazd , IR
    • Posts 149

    Hi , everyone

    I want to show search result as google image search result , how can i do?

    Gridview haven't any horizontal repeatation mechanism and Datalist haven't paging facility.

    any one know any solution?

    Be the best
    Filed under: , ,
  • Re: Paging and datalist?

    12-30-2006, 11:54 AM
    Answer
    • Loading...
    • Caddre
    • Joined on 06-23-2003, 9:53 AM
    • Indy
    • Posts 5,308
    mfarshadmehr:

    Hi , everyone

    I want to show search result as google image search result , how can i do?

    Gridview haven't any horizontal repeatation mechanism and Datalist haven't paging facility.

    any one know any solution?

    If you are using SQL Server 2005 you could use the Row_Number function like the code in the link below.  Hope this helps.

    http://weblogs.asp.net/scottgu/archive/2006/01/07/434787.aspx

    Kind regards,
    Gift Peddie
  • Re: Paging and datalist?

    01-02-2007, 2:17 AM
    Answer
    • Loading...
    • rexlin
    • Joined on 07-17-2006, 4:43 AM
    • Posts 1,751

    Hi, mfarshadmehr:

    You can also use the PagedDataSource  in asp.net 2.0 for paging in datalist

     

     

     

    private void BindData()
    {
        
    //ds fill
        
    DataView dv = ds.Tables[0].DefaultView;
        PagedDataSource Pds = 
    new PagedDataSource();
        Pds.DataSource = dv;
        Pds.AllowPaging = 
    true;
        Pds.PageSize = 10;
        
    int TotalCount = Pds.PageCount;
        
    int CurrPage;
        
    //get page index

        

    CurrPage = Request.QueryString["Page"];
        

        //databind
        
    DataList1.DataSource = Pds;
        DataList1.DataBind();



    Best Regards,
    __________________________________________________
    Sincerely,
    Rex Lin
    Microsoft Online Community Support

    This posting is provided "AS IS" with on warranties, and confers no rights.
  • Re: Paging and datalist?

    03-08-2007, 6:39 PM

    Look my code

    CODE
        Sub BindData()
          
        Dim mydt As New yourdatable()
                Dim tba As New yourobjectTableAdapters.yourtableadaper()

               
                tba.Fill(mydt, Me
    dgPager.CurrentPageIndex * Me.dgPager.PageSize , Me.dgPager.PageSize)
                
                Me.dgPager.VirtualItemCount = yourqueryrecordcount
               
                Me.
    dgPager.DataSource = mydt
                Me.
    dgPager.DataBind()
               
                Me.DataList1.DataSource = mydt
                Me.DataList1.DataBind()

        End Sub

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
            If Not Page.IsPostBack Then
               BindData()

            End If
        End Sub


     Protected Sub dgPager_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
            If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
                e.Item.Visible = False
            End If

        End Sub

     Protected Sub dgPager_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs)
            Me.dgPager.CurrentPageIndex = e.NewPageIndex
            BindData()

        End Sub
    ASPX page

    <form id="form1" runat="server">
            <asp:DataList ID="DataList1" runat="server" RepeatColumns="4" RepeatDirection="Horizontal">
                <ItemTemplate>
                    <%# Eval("YourDataField") %><br />
                </ItemTemplate>
            </asp:DataList>
            <asp:DataGrid ID="dgPager" runat="server" AllowPaging="True" AutoGenerateColumns="False" GridLines="None" PageSize="8" ShowHeader="False" OnPageIndexChanged="dgPager_PageIndexChanged" OnItemCreated="dgPager_ItemCreated" AllowCustomPaging="True">
                                                                                <PagerStyle Mode="NumericPages" />
                                                                                <Columns>
                                                                                    <asp:TemplateColumn>
                                                                                        <ItemTemplate>
                                                                                        </ItemTemplate>
                                                                                    </asp:TemplateColumn>
                                                                                </Columns>
                                                                            </asp:DataGrid>

        </form>

    Lorenzo Battaglia
    Ceo President, LandLogic IT s.r.l.
    Address : via G. Di Vittorio 29
    City: Corato (Bari) Italy
    Postal Code: 70033
    Web: http://www.landlogic.it
Page 1 of 1 (4 items)
Microsoft Communities
Page view counter