DataList Pagination
03 January 2010 Tips  Marek Sienkiewicz
Bubble

By default the DataList control does not have built in paging capability, however we can get round this by using the PagedDataSource class and some code. This is all well documented on the Net, my problem however, was using:

         FirstPage.Enabled = Not pagedData.IsFirstPage
         PrevPage.Enabled = Not pagedData.IsFirstPage
         NextPage.Enabled = Not pagedData.IsLastPage
         LastPage.Enabled = Not pagedData.IsLastPage

 Caused the site to fail W3C validation

 

A work around that worked for me:

If Not pagedData.IsFirstPage Then
            FirstPage.Visible = True
        Else
            FirstPage.OnClientClick = "return false"
            FirstPage.ForeColor = Drawing.Color.Gray
            FirstPage.Attributes.Add("onmouseover", "this.className='hover'")
        End If

        If Not pagedData.IsFirstPage Then
            PrevPage.Visible = True
        Else
            PrevPage.OnClientClick = "return false"
            PrevPage.ForeColor = Drawing.Color.Gray
            PrevPage.Attributes.Add("onmouseover", "this.className='hover'")
        End If
        If Not pagedData.IsLastPage Then
            NextPage.Visible = True
        Else
            NextPage.OnClientClick = "return false"
            NextPage.ForeColor = Drawing.Color.Gray
            NextPage.Attributes.Add("onmouseover", "this.className='hover'")
        End If
        If Not pagedData.IsLastPage Then
            LastPage.Visible = True
        Else
            LastPage.OnClientClick = "return false"
            LastPage.ForeColor = Drawing.Color.Gray
            LastPage.Attributes.Add("onmouseover", "this.className='hover'")
        End If

 






Please post your comments:

Name

Email
                           

   

Enter the text you see in the box:

Captcha Image